-2

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

RoyalGoose
  • 453
  • 9
  • 24

1 Answers1

1

From docs

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)
deadshot
  • 8,881
  • 4
  • 20
  • 39