7.Insert Methods-官方文档摘录

总结

列举insert插入方法

MongoDB provides the following methods for inserting documents into a collection:

db.collection.insertOne() Inserts a single document into a collection.
db.collection.insertMany() db.collection.insertMany() inserts multiple documents into a collection.
db.collection.insert() db.collection.insert() inserts a single document or multiple documents into a collection.

Additional Methods for Inserts

The following methods can also add new documents to a collection:

  • db.collection.update() when used with the upsert: true option.
  • db.collection.updateOne() when used with the upsert: true option.
  • db.collection.updateMany() when used with the upsert: true option.
  • db.collection.findAndModify() when used with the upsert: true option.
  • db.collection.findOneAndUpdate() when used with the upsert: true option.
  • db.collection.findOneAndReplace() when used with the upsert: true option.
  • db.collection.save().
  • db.collection.bulkWrite().

See the individual reference pages for the methods for more information and examples.

你可能感兴趣的:(7.Insert Methods-官方文档摘录)