What the difference between theese methods
.insert_many()
, .save()
, .update()
, .update_many()
?
I want to push the docs to database and if the same doc was exist it will be updated or if no exsist it will be created
What the difference between theese methods
.insert_many()
, .save()
, .update()
, .update_many()
?
I want to push the docs to database and if the same doc was exist it will be updated or if no exsist it will be created
update(spec, document, upsert=False, manipulate=False, multi=False, check_keys=True, **kwargs) Update a document(s) in this collection.
DEPRECATED - Use replace_one(), update_one(), or update_many() instead.
Example query using update_one()
collection.update_one({'key': 'value'}, {'$set': {'new_key': 'new_value'}}, upsert=True)
Using replace_one()
collection.update_one({'key': 'value'}, {'new_key': 'new_value'}, upsert=True)