Database Manual / CRUD Operations / Insert

Insert Methods插入方法

MongoDB provides the following methods for inserting documents into a collection:MongoDB提供了以下将文档插入集合的方法:

Method方法Description描述
db.collection.insertOne()Inserts a single document into a collection.将单个文档插入到集合中。
db.collection.insertMany()Inserts multiple documents into a collection.将多个文档插入到集合中。

If you use MongoDB Atlas, the fully managed service for MongoDB deployments in the cloud, you can use these methods to insert documents after you connect to your cluster. To learn more, see the following resources in the MongoDB Atlas documentation:如果你使用MongoDB Atlas,这是云中MongoDB部署的完全托管服务,你可以在连接到集群后使用这些方法插入文档。要了解更多信息,请参阅MongoDB Atlas文档中的以下资源:

Additional Methods for Inserts插入的其他方法

The following methods can also add new documents to a collection, including collections hosted in MongoDB Atlas:以下方法还可以将新文档添加到集合中,包括MongoDB Atlas中托管的集合:

See the individual reference pages for the methods for more information and examples.有关更多信息和示例的方法,请参阅各个参考页。