-3

私のデータが

db.posts.save({postid:1,postdata:"hi am ",comments:["nice","whats bro"]});

したがって、この場合、コメントを反復する方法は

cursor=selct * from posts;
cursor 1=selct * from comments where postid=:cursor.postid
for (i in cursor)
for(j in cursor1)
4

1 に答える 1

1

コメントを反復処理する 1 つの方法は次のとおりです。

db.posts.find().forEach(
  function(doc) {
    // iterate over the comments in your preferred javascript way
    var i;
    for (i=0; i<doc.comments.length; ++i) {
      // Do whatever you want with doc.comments[i] here
    }
  }
)
于 2013-09-17T19:18:13.793 に答える