Modify all the documents in my database

Hello I just started the mongodb with nodejs and react on the front side.

I’m looking for a way to do a “Put” request and change all the data at once
I have a model called “Vote” in which I want to add +1 , I would like to do it for all my database

thank you

Please provide sample input documents and expected result. Also share what you have tried and explain how it fails to provide you with the expected result.

Read before posting documents and code:

Method you need to update all documents:

The filter argument is {} to specify all documents.
The update parameter you need is

Thank you for your reply

Currently i do it individually against each id

But I would like to do it for all at once = (req, res) => { 
    let edition;
    edition = {vote: ( + 1) };
    const update = { $set: edition };
    /*    const update = { $set: edition }; */
    const id =;
    const conditions = { _id: id };
    const options = {
        upsert: true,
        new: true
    Project.findOneAndUpdate(conditions, update, options, (err, response) => {
        if (err) return res.status(500).json({ msg: 'update failed', error: err });
        res.status(200).json({ msg: `document with id ${id} updated`, response: response });


I would like to make + 1 to the vote, a on all my database and not only on the selected id

Thanks I succeeded using updateMany() and $inc

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.