How to project updated values only using findOneAndUpdate in embedded array Mongoose?
问题 Currently my User model looks like: { _id: 'SomeId' firstName: 'John', lastName: 'Cena', books: [ { _id: 'xyz', title: 'a', author:'b', ratings:[ {source:'source1', value:"8"}, {source:'source2', value:"9"}] }, { _id: 'abc', title: 'c', author:'d', ratings:[ {source:'source3', value:"7"}, {source:'source4', value:"5"}] } ] } After making an findOneAndUpdate query to update rating=>value of 1st book object(_id: "xyz") from 8 to 10 for a given source(say "source1") : let up={ 'books.$[book]