add tag
Anonymous 1731
I have below json data and want to update the value according to the condition


```
{
    "_id" : ObjectId("5fce2d4c7b2ea2e79ercvju4"),
    "userId" : 1,
    "token": "jwt_token_value",
    "isActive" : 0,
    "__v" : 0
}
{
    "_id" : ObjectId("5fce2d4c7b2ea2e79ercvjk0"),
    "userId" : 1,
    "token": "jwt_token_value",
    "isActive" : 0,
    "__v" : 0
}
{
    "_id" : ObjectId("5fd0d45tjd82a02dd0f17fc4"),
    "userId" : 1,
    "token": "jwt_token_value",
    "isActive" : 1,
    "__v" : 0
}
```

I have managed the things as below.


```
let update = await UserDetails.findAndModify(
    { userId: 1, token: token },
    [],
    {$set: { isActive: 0 }},
    { new: true }
);
```

=> This query should update the last json collection key of isActive to 1. But it is not updating the values any how. What the things that I am doing wrong ? It is not throwing me any error as well to debug.

This room is for discussion about this question.

Once logged in you can direct comments to any contributor here.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.