Blank screen after running script

Ron Tran shared this problem 6 years ago
Cannot Reproduce

I have a collection with 3 million docs. After I run this script, I get a blank white window with nothing inside it. I tried on different machines with different databases too.

db.Transaction.find({}).snapshot().forEach((it) => {

db.Transaction.update({ _id: it._id }, {

$set: {

Items: [{

"Amount": it.Amount, "Memo": it.Memo, "ItemType": it.TransactionType

}], "Total": it.Amount

}

})


});

Replies (6)

photo
1

I tried your script with 1M test data, but can't recall your issue locally.


Update the millions of records one by one will be very slow, it may look like that UI is not responding.

photo
1

The menu still responds but the window is blank. It has been 24 hours since I left it there.

39f5f2738271dadcc14563d3cf472755

photo
1

Is there a way to hide the script runtime log?

photo
1

There is no way to hide the script run-time log , when the amount of data is very large, this will indeed be a serious UI problem, I will add an option in the next version.

photo
1

Updating the data one by one is not efficient, I think you can use bulk.find.update(). https://docs.mongodb.com/manual/reference/method/Bulk.find.updateOne/


e.g.


let bulk = db.Transaction.initializeUnorderedBulkOp();

let idx = 0;

db.Transaction.find({}).snapshot().forEach((it) => {
    idx++;

    if (idx % 1000 === 0) {
        console.log("No."+idx);
    }

    bulk.find({ _id: it._id }).update({
        $set: {

            Items: [{

                "Amount": it.Amount, "Memo": it.Memo, "ItemType": it.TransactionType

            }], "Total": it.Amount

        }
    });
});

console.log("bulk.exeucte")

bulk.execute();

photo
1

Mongobooster crashed at 3.5 mill docs........I have 3.9. For now I am running it server side.

Leave a Comment
 
Attach a file