For instance, I have a collection User:
User
var mongoose = require(\'mongoose\'); var UserSchema = new mongoose.Schema({ email: String, googleI
OR you can simply use exists function, without making any async/await:
myData = {_id: userID}; User.exists(myData,(error, result)=>{ if (error){ console.log(error) } else { console.log("result:", result) //result is true if myData already exists } });
You can play with the result now!