I have mongoose Shcema:
Track = new Schema({
title: ‘string’,
artist: ‘string’
})
in my DB collection I’ve got object:
{
title: ‘title1’,
artist: ‘artist1’,
status: ‘1’
}
Status is not in schema but it is still retrieved by find methods. I thought that schema should be able to restrict this.
Is it possible to retrieve this object by findOne ore findById etc without status attribute being automatically excluded without need to explicitly point it out by {status: 0}?
You can do this by adding the
statusfield to the schema but setting its selection default tofalse: