Can’t find any items using nested object for searching in deleteMany()

I am trying to delete some items from the MongoDB using mongoose deleteMany function.

I am using a nested object for finding matched items but it can't find any match. But when I try the same thing with a normal object it matches.

how I can use a nested object to find match items and delete them. here is my code

var j = { user: { id: "60f701497862990f20f959c7", username: "munna", name: "Munna" } }





{ n: 0, ok: 1, deletedCount: 0 } //this is the output

and this is the schema... var answerSchema = new mongoose.Schema({

user: {
    id: String,
    username: String,
    name: String
answer: String,
marks: Number,


Read more here:

Content Attribution

This content was originally published by MD Ripon Islam at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: