I'm trying to remove the particular field from mongo document using mongoose.But it's not working.
Here my mongo document:
{
"_id" : ObjectId("5da80eb605320f441c41e340"),
"name" : "TEST1-_-m3mkf9",
"users" : [
{
"formStatus" : "assigned",
"form" : [
{
"_id" : ObjectId("5da80eb505320f441c41e33d"),
}
],
}
]
}
Here my code:
await Promise.all(
Form.update(
{ _id: "5d8da115e222df7ebc066175" },
{ $pull: { users: 1 } },
{ safe: true }
)
)
.then(async val => {})
.catch(err => {
console.log(err);
});
I want to remove the users field from mongo document. How can i do it? Thanks in advance.