Mongodb’s Uncertain Number of Executions

  mongodb, question
var all = db.getCollection('logging').find({"Properties.EnterpriseId":{$ne:null},"Properties.AccountId":null}).sort({"Date":-1});
 if(value.Properties.AccountId == null){
 db.logging.update({'_id':ObjectId(value._id.str)},{$set:{'Properties.AccountId':value.Properties.EnterpriseId}}, false, true)

The above code only updates 100 pieces at a time, sometimes only updates a few hundred pieces, and 200,000 pieces of data cannot be updated completely at one time. Why is this?

There are several points that are not very clear:

  1. It looks like a shell script, doesn’t it?

  2. Since the conditions include{"Properties.AccountId":null}, whyif(value.Properties.AccountId == null)? Or what you want to judge isAccountId === null?

  3. updateDetails of the method can be viewedDocument. The definition in the document is:db.collection.update(query, update, options), so I don’t know the lastfalseAndtrueWhat was the intention?upsertAndmulti? In this case, it should be:

    db.logging.update({'_id':ObjectId(value._id.str)},{$set:{'Properties.AccountId':value.Properties.EnterpriseId}}, {upsert: false, multi: true})

    But you’re using_idThere should be no conditionsmultiWhat is it? Well, it’s better to say clearly what you meant, so I won’t speculate.

  4. You are using cyclic updates, and each cycle is conditional. If you want to update 200,000 items, can these conditions cover the complete 200,000 items of data?