批量更新字段
db.ch_clinic_reservation.update(
{"CH_source": {$exists: false}},
{"$set": {"CH_source": "patient"}},
false,
true
)
参数1:条件
参数2:更改
参数3:false 表示如果没有就不更新
参数4:true 表示一次更新多条
db.ch_clinic_reservation.find({}).forEach(
function(i){
i.CH_modify_status=NumberInt(0);
db.ch_clinic_reservation.save(i);
}
);
mongodb比较时间大小
db.ch_clinic_reservation.update(
{"CH_time": {"$lt": ISODate("2019-10-11T00:00:00.000Z")}},
{"$set": {"CH_signed": true, "CH_is_treated": true}},
false,
true
)