rxdb icon indicating copy to clipboard operation
rxdb copied to clipboard

Error "Update expression must contain only one operator"

Open DanielKucal opened this issue 1 year ago • 1 comments

After update to v15, the following code started to throw an error:

DB_INSTANCE.my_collection.findOne({
      selector: { /*...*/ },
    }).update({
      ...data,
      title: 'newTitle',
    });

Error thrown: image Release note doesn't mention any change to the update method.

DanielKucal avatar Jan 30 '24 05:01 DanielKucal

Since v15 we use the mingo library for updates: https://github.com/kofrasa/mingo?tab=readme-ov-file#updating-documents

I do not think your given update statement is valid because it does not contain a $ operator.

pubkey avatar Jan 30 '24 16:01 pubkey

Closing this. I think the correct call would be like:

DB_INSTANCE.my_collection.findOne({
      selector: { /*...*/ },
    }).update({
      $set: {
        ...data,
        title: 'newTitle',
      }
    });

pubkey avatar Feb 07 '24 22:02 pubkey