最后更新于
MongoDB 提供了以下方法将文件插入集合:
将单个文档插入到集合中。
db.collection.insert()将单个文档或多个文档插入到集合中。
以下方法还可以向集合中添加新文档:
与upsert: true选项一起使用时db.collection.update()。
与upsert: true选项一起使用时db.collection.updateOne()。
与upsert: true选项一起使用时db.collection.updateMany()。
与upsert: true选项一起使用时db.collection.findAndModify()。
与upsert: true选项一起使用时db.collection.findOneAndUpdate()。
与upsert: true选项一起使用时db.collection.findOneAndReplace()。
有关更多信息和示例,请参阅方法的各个 reference 页面。
译者:杨帅
校对:杨帅
最后更新于