I am trying to check if the record exists inside the model using beforeCreate
/api/models/User.js
beforeCreate: function (values, cb) {
User.findOne(values.email).exec(function findOneCB(err,found){
console.log('We found '+found.name);
});
},
I get
TypeError: Object #<Object> has no method 'findOne'
Is there a way to avoid doing that from the controller?