MongoCollection.insert

void insert(T)(T document_or_documents, InsertFlags flags = InsertFlags.None)
deprecated Use `insertOne` or `insertMany`, this method breaks in MongoDB 5.1 and onwards.

Inserts new documents into the collection.

Note that if the _id field of the document(s) is not set, typically using BsonObjectID.generate(), the server will generate IDs automatically. If you need to know the IDs of the inserted documents, you need to generate them locally.

Throws

Exception if a DB communication error occurred.

See Also