How can use mongodb and node js with complicated query

Clash Royale CLAN TAG#URR8PPP
How can use mongodb and node js with complicated query
I want in node js use mongodb.
I can insert,update ,.... in mongo with node. for example i can select with find but i can not Input the result of one query1 for query2.

1 Answer
1
You can first get all the records from the collection that match the where query then loop over to those records to update only those resultant records that have c=4:
where
c=4
MyCollectionName.find(a:$gt: 4, b:$gt: 3, function findResult(err, findResult)
if (err)
console.log('Error on find');
return;
findResult.forEach(function (result)
if(result.c === 4)
result.c = 5;
result.save(function saveResult(err, savedResult)
if (err)
console.log('Error on save');
return;
console.log('Updated...');
return;
);
);
);
Where, MyCollectionName is the mongoose model for the collection you wish to query.
MyCollectionName
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
can we do that without forEach and for , while ,....?
– Moh_beh
Aug 7 at 12:13