I have notes nested in userSchema I am trying to delete one object by _id but deleteOne is removing the whole user object so how can I can delete the one with _id
const keeperSchema = mongoose.Schema({
noteName:String,
noteContent:String,
})
const userSchema = mongoose.Schema({
email:String,
password:String,
notes:[keeperSchema]
})
app.post("/delete",(req,res)=>{
const id=req.body.id
const email=req.body.email
console.log(id)
Keeper.deleteOne({"notes._id":id}).then(()=>{
Keeper.find({email:email},(err,results)=>{
if(results){
console.log(results)
}
})
})
})