Skip to content

ValueError: update only works with $ operators #50

@ramuta

Description

@ramuta

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions