Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function oid(id) {
- try {
- return ObjectId(id);
- } catch(e) {
- return id;
- }
- }
- var counter = 0;
- var stageConn = new Mongo("10.10.80.227:27017");
- var stage = stageConn.getDB("rldd2");
- var remove = stage.xx_deadline_aggr.remove({});
- db.persons.find({ "type": { $ne: "JURIDICAL" }}).addOption(DBQuery.Option.noTimeout).forEach(function(person){
- if(person != undefined ){
- if(person.registrationAddressId != undefined )
- {var registrationAddressId = oid(person.registrationAddressId);}
- else {var registrationAddressId = oid(0);}
- if(person.locationAddressId != undefined )
- {var locationAddressId = oid(person.locationAddressId);}
- else {var locationAddressId = oid(0);}
- //printjson(registrationAddressId);
- //printjson(locationAddressId);
- var regAddr = db.addresses.findOne({"_id": registrationAddressId});
- var locAddr = db.addresses.findOne({"_id": locationAddressId});
- // printjson(regAddr);
- //printjson(locationAddressId);
- if(regAddr != undefined )
- {var regArea = regAddr.area;}
- else {var regArea = "1";}
- if(locAddr != undefined )
- {var locArea = locAddr.area;}
- else {var locArea = "1";}
- if(regArea == undefined ){var regArea = "1";}
- if(locArea == undefined ){var locArea = "1";}
- //printjson(regArea);
- //printjson(locArea);
- //printjson(regArea);
- //printjson(locArea);
- if( regArea.indexOf("химк") >=0 || regArea.indexOf("Химк") >=0 ||regArea.indexOf("ХИМК") >=0 || locArea.indexOf("химк") >=0 || locArea.indexOf("Химк") >=0 ||locArea.indexOf("ХИМК") >=0)
- {
- stage.xx_deadline_aggr.save(person);
- counter = counter + 1;
- }
- }
- });
- print("Total " + counter + " persons.");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement