Adding a document to the database involves using either the insert_one() or insert_many() method from the pymongo.collection.Collection class. The generic syntax for insert_one() is as follows. The parameters enclosed in square brackets [] are optional:
insert_one(<document>, [<bypass_document_validation>, <session>])
The generic syntax for insert_many() is also shown here. The parameters enclosed in square brackets [] are optional:
insert_many(<iteration of documents>, [<ordered>, \
<bypass_document_validation>, <session>])
The more important parameters are summarized here:
Parameter | Default | Notes |
document(s) | -- | For insert_one(), this is a single document. For insert_many(), this is an iteration of documents. |
bypass_document_validation |
False | If set to True, the write operation is instructed not to validate. This improves performance at the cost of the... |