Moongose query for finding unique document

Viewed 33
json: {
  data:{
    base:"Id",
  },
  res:{
    message:"sddg"
  }
}

I want to find if a particular record already exist on the basis of base unique attribute using Mongoose in MongoDB database, but unable to do so. My approach is:

model.findOne({data:{base:"Id"});
1 Answers

You should do it like this:

model.findOne("data.base": "Id")
Related