0
    db = db.getSiblingDB("aqua") //same as use otherdb
    var legalStatus=["initiate","process","complete","replicating","failed","offline_complete","offline_fail","invalid"];
    var replicas=db.aquaObject.find({"replicas":{$ne:null},"replicas.status":{$nin:legalStatus}});
    replicas.forEach(
function(t){
    db.aquaObject.update(t,{$set:{"replicas.0.status":"initiate"}});
});

这是我写的脚本。但是 find 方法中的条件:"replicas.status",这里replicas是一个数组。我想迭代所有副本并过滤每个副本的状态。所以我相信我写的东西是不正确的。我该如何完善它?谢谢。

4

0 回答 0