Unable to use update pipeline with findOneAndUpdate


I am not able use update pipeline with findOneAndUpdate and need help with the same.

db.getCollection('test').findOneAndUpdate({ lastAssignedTime: {$lt: new Date((new Date())-1000*10)} },
                    if: {$gte: ["$vmAssignedSessions", 3]},
                    then: 99,
                    else: 1,
 {sort: { "priority" : 1 }}

I keep running into

021-03-03T17:24:11.474-0800 E QUERY [js] Error: the update operation document must contain atomic operators :

Mongo component versions:
MongoDB shell version v4.0.0

connecting to: mongodb://

MongoDB server version: 4.2.12

Thanks in advance!

Hello @Abhishek_Kumar_Singh,

aggregation pipeline is support from mongodb v4.2, i can see your server version is valid but You have to update your mongodb shell version to 4.2 or above.


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.