Announcement Announcement Module
Collapse
No announcement yet.
Bulk update recommendation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bulk update recommendation

    Hi,

    I've a collection as

    {
    "code" : "someCode",
    price: 3.14,
    volume : 6.28
    }

    I have more then 10 millions of row in this collection and i need to multiply price and volume fields with a number. Because of the row count i don't prefer to retrieve&update so i need a server side solution.
    We have $inc with mongodb but nothing line $multiply, then i created a function as

    db.collectionName.find().forEach( function(t) {
    var price = t.p * 2;
    var volume = t.v * 2;
    db.collectionName.update({_id: t._id}, { $set: { p: price, v:volume } });
    })

    i can execute it from mongo shell and it's ok, but i couldn't find a way to execute it from spring mongo environment, is there a way for that or you have any different ideas for that kind of bulk update?
Working...
X