在 MongoDB 中,我知道可以像这样进行批量更新:
bulk.find( { status: "D" } ).update( { $set: { status: "I", points: "0" } } );
这将匹配“状态”为“D”的所有文档。
find
是否可以在零件总是在变化的情况下执行类似的操作?
换句话说,我可以在一次操作中完成这一切吗?
bulk.find( { status: "A" } ).update( { $set: { status: "X", points: "1" } } );
bulk.find( { status: "B" } ).update( { $set: { status: "Y", points: "2" } } );
bulk.find( { status: "C" } ).update( { $set: { status: "Z", points: "3" } } );