-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Labels
confirmed-bugWe've confirmed this is a bug in Mongoose and will fix it.We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Description
I have a collection documents with a document that looks like this:
{
"_id" : ObjectId("5d7ddedf92264a43ceee9f48"),
"name" : "test123",
"predictedEntityValues" : [
{
"status" : "DONE",
"values" : [
{
"text" : "123"
}
]
}
]
}
I have the following query where documentIds = [ ObjectId("5d7ddedf92264a43ceee9f48") ]
await models.documents
.updateMany(
{ _id: { $in: documentIds } },
{
$pull: {
predictedEntityValues: { 'values.0.coords': { $exists: false } },
},
}
)
The above query should should remove the value in the array 'predictedEntityValues', but it doesn't.
My query is correct because when I execute it into the mongo shell, it works.
I turned on debug mode, and I saw that the library parsed my query to this query:
Mongoose: documents.updateMany({ _id: { '$in': [ ObjectId("5d7ddedf92264a43ceee9f48") ] } }, { '$setOnInsert': { createdAt: new Date("Sun, 15 Sep 2019 06:42:51 GMT") }, '$set': { updatedAt: new Date("Sun, 15 Sep 2019 06:42:51 GMT") },
'$pull': { predictedEntityValues: { 'values.0.coords': {} } } }, {})
As you can see, it removes the $exists false in the parsed query: { predictedEntityValues: { 'values.0.coords': {} } } }
Metadata
Metadata
Assignees
Labels
confirmed-bugWe've confirmed this is a bug in Mongoose and will fix it.We've confirmed this is a bug in Mongoose and will fix it.