I have two collections The structure of collection A is
{
id:
product:
}
The structure of collection B is
{
id:
product:
status:
}
I want to update collection B like if a product exists in collection A, then it will set status 1 to the corresponding document of collection B.
The SQL syntax would be like
UPDATE B SET B.STATUS = 1 WHERE B.PRODUCT IN (SELECT PRODUCT FROM A);
I just need to do the same in MongoDB. Thanks in advance.
In MongoDB 4.2 you can do this with aggregation.
status: {$literal:1}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.