插入方法
MongoDB提供了以下方法来插入文档到集合中
如果您使用MongoDB Atlas,云中MongoDB部署的全托管服务,您可以在连接到您的集群后使用这些方法来插入文档。有关更多信息,请参阅MongoDB Atlas文档中的以下资源
插入的其他方法
以下方法也可以向集合添加新文档,包括托管在MongoDB Atlas中的集合
db.collection.updateOne()
与upsert: true
选项一起使用。db.collection.updateMany()
与upsert: true
选项一起使用。db.collection.findAndModify()
与upsert: true
选项一起使用。db.collection.findOneAndUpdate()
与upsert: true
选项一起使用。db.collection.findOneAndReplace()
与upsert: true
选项一起使用。
有关更多信息和方法示例,请参阅各个参考页面。