English 中文(简体)
mongodb nodejs - 转换循环结构
原标题:mongodb nodejs - converting circular structure

我有几部法典,将所有文件从收集中删除,并放在网页上。 简略版本就是这样:

var mongodb = require("mongodb"),
    express = require("express"),
    mongoServer = new mongodb.Server( localhost , 27017),
    dbConnector = new mongodb.Db( systemMonitor , mongoServer),
    db;

var app = new express();

app.get( /drives , function(req, res) {
  db.collection( driveInfo , function(err, collection) {
    if (err) throw err;
    collection.find({}, function(err, documents) {
      res.send(documents);
    });
  });
});

dbConnector.open(function(err, opendb) {
  if (err) throw err;
  db = opendb;
  app.listen(80);
});

我有一份载有长篇文件清单的自动信息资料收集。 每一份文件都载有密封物体。 我想做的是,在有人访问浏览器/浏览器时,把整个收藏品印制成son子,以便我能够 later笑以后(一纸pi的gin首)一切。

然而,我有一处错误,说“TypeError:将循环结构改变为JSON”。 页数中这一行码的错误:

collection.find({}, function(err, documents) {
  res.send(documents);
});

I m unsure what the problem is, or where the self-reference is. Am I not querying the collection properly?

最佳回答

不知道您使用哪种文本,但认为您的辛迪加可能错误地看待安普森图谱:

http://docs.mongodb.org/manual/vis/method/db. Collection.find/

This is the declaration:

db.collection.find(<criteria>, <projection>)

你们肯定会误用预测参数。 通过像你那样的警示,看来会回来db的标语,从而在JSON的序号中造成循环错误。

找到所有业务的正确守则应当如下:

collection.find({}).toArray(function(error, documents) {
    if (err) throw error;

    res.send(documents);
});
问题回答

在我的案件中,我正在发现错误,因为我正在问(使用长官寻找方法)而没有等待。 请参看下文。

www.un.org/Depts/DGACM/index_spanish.htm 造成错误的证据(因为我没有在等待的情况下执行这一询问):

const tours = Tour.find({
    startLocation: {
      $geoWithin: { $centerSphere: [[longitude, latitude], radius] }
    }
  });

否则,我会因以下原因去找曼:

"message": "Converting circular structure to JSON
    --> starting at object with constructor  NativeTopology 
    |     property  s  -> object with constructor  Object 
    |     property  sessionPool  -> object with constructor  ServerSessionPool 
    --- property  topology  closes the circle"

www.un.org/Depts/DGACM/index_spanish.htm 我如何消除上述错误(await):

 const tours = await Tour.find({
        startLocation: {
          $geoWithin: { $centerSphere: [[longitude, latitude], radius] }
        }
      });

const res1 = 等待收集(“有些-db”)。

这里,第1款将包含有循环结构的“保证人”,因此所发现的错误被推翻。

添加<代码>const res2 = 等待代码第1.toArray()>。

此处,res2 现在将包含一系列文件,由曲线人res1标明,这些文件是你询问的文件。

就我而言,我不得不等待<代码>.find()方法,并在回复中发出未解决的承诺。

修改如下:

const posts = Post.find({});

为此:

const posts = await Post.find({});




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签