Wednesday, 31 May 2017

Mongoose async/await find then edit and save?

Is it possible to do a find then save using async/await promise?

I have the following code:

try {
    var accounts = await Account.find()
        .where("username").in(["hello@hello.com"])
        .exec();
    accounts.push({username: "test@test.com"});
    accounts.save();
} catch (error) {
    handleError(res, error.message);
}

and I am getting the following error:

ERROR: accounts.save is not a function



via Tom Krones

No comments:

Post a Comment