So I have these 2 schemas and it won't let me have one object only but it returns the whole array of objects instead
const ReqEmbSchema = new mongoose.Schema({
appId: String,
lname: String,
fname: String,
midname: String
});
const RequestSchema = new mongoose.Schema({
appId: String,
userRequest: [ReqEmbSchema]
});
I tried doing this to get 1 specific embedded object from ReqEmbSchema
const update = "zDfXUoQhc8";
Request.findOne({'userRequest.appId': update}, function(err,foundRequest){
console.log(foundRequest);
});
But sadly it returns all embedded objects in my log. Please help me fix .