Reputation: 381
I have written this command into robomongo:
db.FinalLocation.find({UserName: null}).forEach(
function (obj)
{
db.tempColl.save(obj)
});
Now, I want to know how many documents Have been found into FinalLocation collection and how many documents Have been inserted into tempColl collection?
I know by db.tempColl.count()
can find but I want, at the end of my script appear something like this:
Total empty object : 36 ---> at FinalLocation
Total inserted object : 36 ---> at tempColl
Upvotes: 1
Views: 575
Reputation: 381
I finally solved this problem: this is my code:
var result = db.FinalLocation.find({UserName: null}).toArray()
print("Total empty object: "+ result.length);
var t = db.tempColl.insertMany(result);
print("Total inserted object: "+ t.insertedIds.length);
This outPut:
Total empty object: 36
Total inserted object: 36
Upvotes: 1