xxxxxxxxxx
// User model
const User = mongoose.model('User', {
name: { type: String },
age: { type: Number }
});
User.exists({name:'Gourav'}, function (err, doc) {
if (err){
console.log(err)
}else{
console.log("Result :", doc) // false
}
});
User.exists({name:'Amit'}, function (err, doc) {
if (err){
console.log(err)
}else{
console.log("Result :", doc) // true
}
});