I have the following mongoose schema:
user = {
\"userId\" : \"myId\",
\"connections\":
[{
\"dateConnectedUnix\": 1334567891,
\"is
mongoose: 4.11.11
What have worked for me is the following syntax:
const removeTansactionFromUser = (userId, connectionId) => {
return User.findByIdAndUpdate(userId, { $pull: { "connections": connectionId} }, {'new': true} );
};
Mongoose support id in string format or ObjectId format.
Tip: new ObjectId(stringId)
to switch from string to ObjectId