I need to return user from my service model to controller model but i am not able to do that can anybody help me that ?
async function create(userParam) {
if (await User.findOne({ username: userParam.username })) {
throw 'Username "' + userParam.username + '" is already taken';
}
const user = new User(userParam);
console.log("User", userParam , user )
// hash password
if (userParam.password) {
user.hash = bcrypt.hashSync(userParam.password, 10);
}
// return user from here
await user.save();
}