1.find()
var cursor = collection.find(query, [fields], options);cursor.sort(fields).limit(n).skip(m). cursor.nextObject(function(err, doc) {}); cursor.each(function(err, doc) {}); cursor.toArray(function(err, docs) {}); cursor.rewind() // reset the cursor to its initial state.
2.insert()
collection.insert(docs, options, [callback]);Useful options:(*)
safe:trueShould always set if you have a callback.
3.update()
collection.update(criteria, objNew, options, [callback]);Useful options:(*)
safe:trueShould always set if you have a callback.multi:trueIf set, all matching documents are updated, not just the first.upsert:trueAtomically inserts the document if no documents matched.
4.findAndModify()
Useful options:(*)
remove:trueset to a true to remove the object before returningnew:trueset to true if you want to return the modified object rather than the original. Ignored for remove.upsert:trueAtomically inserts the document if no documents matched.
本文介绍了MongoDB中find、insert、update及findAndModify等基本操作的使用方法与选项设置,帮助读者快速掌握这些常用功能。
1511

被折叠的 条评论
为什么被折叠?



