schapman1974 / tinymongo

A simple wrapper to make a flat file drop in raplacement for mongodb out of TinyDB
MIT License
199 stars 32 forks source link

ValueError: update only works with $ operators #50

Open ramuta opened 5 years ago

ramuta commented 5 years ago

TinyMongo allows you to update a document like this:

collection.update_one({"_id": "fh98h43f89fh4fh"}, {"some_field": "some update"})

But on the real MongoDB database (on mLab) I get this error: ValueError: update only works with $ operators.

So I needed to change the code like this:

collection.update_one({"_id": "fh98h43f89fh4fh"}, {"$set": {"some_field": "some update"}})

This also works on TinyMongo and it is a more appropriate way to update a document. TinyMongo should follow the MongoDB/pymongo behaviour and throw the same error in the first case.

hewsgm123 commented 1 year ago

i have already using $ operators but its giving error: servers.update_one({'_id': str(ctx.guild.id)}, {'$set': {'prefix': prefix}}, upsert=True)

Maribel-88 commented 2 months ago

Thank you, works for me.