Using values in a cursor as qualifier value within Mongosh

Hello,

I was wondering if it is possible through Mongosh to the values in a cursor as values in a query qualifier like so:

var myCursor = db.foo.find({field1:‘abc’}, {field2:1});

while (myCursor.hasNext()) { db.foo.updateOne({field2: myCursor.next() }, { $set :{field1: ‘xyz’}})

I tried the following but they all give syntax errors on "field2:myCursor.next():

var myCursor = db.foo.find({field1:‘abc’}, {field2:1});

while (myCursor.hasNext()) { db.foo.updateOne({field2: myCursor.next() }, { $set :{field1: ‘xyz’}})

and

var myCursor = db.foo.find({field1:‘abc’}, {field2:1});

while (myCursor.hasNext()) { db.foo.updateOne(myCursor.next(), { $set :{field1: ‘xyz’}})

I want Mongosh to recognize that myCursos.next() = field2:.

Thanks

John

Please read Formatting code and log snippets in posts and then update your post so that your code is readable.