Wednesday, 12 April 2017

Updating a list of MongoDB docs

I have a list of documents that i want to update in mongoDB. I send it to the API as a JSON array.

How can I update all the docs without putting the Document.update() into a loop?

I was looking at the $in modifier but i'm not sure how to pass in the actual data to the method.

    var docs = req.body
    Card.update(
        {_id: {$in: docs}},
        {whatgoeshere?}
    )



via Kevin Toet

No comments:

Post a Comment