Error with findOneAndUpdate in ssd

when i tried to update the doc of books i got an error called = Update document requires atomic operators

i know this error is because of we are not using methods like set instead we are passing raw data but how can i solve this issue and update the document using this findOneAndUpdate

Hello @Aswin ,
You can use $set to update the document like this:

bh.local.bookToUpdate = {
  $set: {
    isbn,
    title: book.title,
    authors: book.authors || [],
    publish_date: book.publish_date,
  },
};

in script node

Then, use this bookToUpdate in your MongoDB update query with findOneAndUpdate.

1 Like