I am working on user signup with nodejs and mongo db , problem is when i inserted all data into collection it's returning all the data in the document i want to restrict some of objects in returning data for example in below example in user object password in included which i should restrict ,
newUser = new UserSchema({
firstName : firstName,
middleName : middleName,
lastName : lastName,
email : email,
location : location,
password : password,
createdDate :new Date(Date.now()).toISOString(),
role : "user"
})
password : { // in scehma
type: String,
select :false,
hide: true,
required:true
},
newUser.save((err,user) => {
if(err){
return false;
}else{
return user ; // user object should not have password in this
}
});