Insert Methods插入方法
MongoDB provides the following methods for inserting documents into a collection:MongoDB提供了以下将文档插入集合的方法:
db.collection.insertOne() | |
db.collection.insertMany() |
Additional Methods for Inserts插入件的其他方法
The following methods can also add new documents to a collection:以下方法也可以将新文档添加到集合中:
db.collection.updateOne()
when used with the与upsert: true
option.upsert:true
选项一起使用时。db.collection.updateMany()
when used with the与upsert: true
option.upsert:true
选项一起使用时。db.collection.findAndModify()
when used with the与upsert: true
option.upsert:true
选项一起使用时。db.collection.findOneAndUpdate()
when used with the与upsert: true
option.upsert:true
选项一起使用时。db.collection.findOneAndReplace()
when used with the与upsert: true
option.upsert:true
选项一起使用时。db.collection.bulkWrite()
.
See the individual reference pages for the methods for more information and examples.有关方法的更多信息和示例,请参阅各个参考页。