Question: The code below works, it updates a record or creates one if it doesn't exist yet. However, I'd like to combine this `findOneAndUpdate()` statement with the `populate()` method in order to populate the "user" of my object. What would be the right way to add the `populate("user")` statement to this logic?

I tried adding the `populate()` method after the `findOneAndUpdate` finishes but that returns an error saying that this method doesn't exist. I'm running the latest version of mongoose.

```
LoyaltyCard.findOneAndUpdate({ business: businessid}, { $set: newCard, $inc: { stamps: +1 } }, { upsert: true}, function(err, card){

    if(err)
    {

    }
    else
    {

    }

    res.json(result);
});

```

Answer: 
Use `exec()` instead of a callback parameter:

```
LoyaltyCard.findOneAndUpdate(
        {business: businessid},
        {$set: newCard, $inc: {stamps: +1}},
        {upsert: true}
    )
    .populate('user')
    .exec(function(err, card) {
        if (err) {
            // ...
        } else {
            res.json(result);
        }
});

```
You can also add a `populate` object in the 3rd parameter of `.findOneAndUpdate()` as one of the option, like this:

```
LoyaltyCard.findOneAndUpdate(
        { business: businessid },
        { $set: newCard, $inc: { stamps: +1 } },
        { upsert: true, populate: { path: 'user' } }
    )
    .exec(function(err, card) {
        if (err) {
            // ...
        } else {
            res.json(result);
        }
});

```