node.js - Mongoose Exclude a field if it doesn't match but not the doc -
i've got invitation system , want know if user has been invited or not. every time user invited, notification array updated targeted offer's id.
model
... notification:[ { offer: {type:schema.types.objectid, ref:'offer'}, invitor:{type:schema.types.objectid, ref:'user'}, createat: {type:date, default:date.now()} } ] ....
so goal when query user display notification field if offer's id in notification's array , not if doesn't contain it.
Comments
Post a Comment