-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
{$exists: false} not working for nested fields in $pull statement #8166
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Comments
vkarpov15
added
the
has repro script
There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
label
Sep 23, 2019
Fix will be in 5.7.3. As a workaround, add const assert = require('assert');
const mongoose = require('mongoose');
mongoose.set('debug', true);
const GITHUB_ISSUE = `gh8166`;
const connectionString = `mongodb://localhost:27017/${ GITHUB_ISSUE }`;
const { Schema } = mongoose;
run().then(() => console.log('done')).catch(error => console.error(error.stack));
async function run() {
await mongoose.connect(connectionString, { useNewUrlParser: true });
await mongoose.connection.dropDatabase();
const Model = mongoose.model('Test', Schema({
name: String,
predictedEntityValues: [{
status: String,
values: [{ text: String, coords: [Number] }]
}]
}));
await Model.create({
"_id" : new mongoose.Types.ObjectId("5d7ddedf92264a43ceee9f48"),
"name" : "test123",
"predictedEntityValues" : [
{
"status" : "DONE",
"values" : [
{
"text" : "123"
}
]
}
]
});
await Model.updateMany(
{},
{
$pull: {
predictedEntityValues: { 'values.0.coords': { $exists: false } },
},
}
)
} |
vkarpov15
added
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
and removed
has repro script
There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
labels
Sep 25, 2019
This was referenced Mar 11, 2021
Open
This was referenced Mar 18, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a collection documents with a document that looks like this:
I have the following query where documentIds = [ ObjectId("5d7ddedf92264a43ceee9f48") ]
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:
As you can see, it removes the $exists false in the parsed query:
{ predictedEntityValues: { 'values.0.coords': {} } } }
The text was updated successfully, but these errors were encountered: