R
R
Rostyslawn2022-02-19 20:15:53
Node.js
Rostyslawn, 2022-02-19 20:15:53

Does not update the parameter in the database, what should I do?

It is necessary for each user in the database to update the parameter from falsetotrue

let a = 123;
if(a == 123) {
    User.find({}, (err, doc) => {
            if(err) console.log(err);

            User.updateMany({parametr: false}, {parametr: true});
        });
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rag'n' Code Man, 2022-02-19
@Rostyslawn

Well, if each user is in the database, then this can be simplified to: But your version with the search for everyone who should also work. Not really, except, I understand, why the heck is this block with the search for all documents.
User.updateMany({}, { parameter: false })
if

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question