Before $unwind check if sub document is not empty
问题 I have a Job schema that has job_title, job_location, salary, etc ApplicationSchema is embedded sub document into Job document and it stores all the applications that this particular job has received Here is how Job Schema looks const jobSchema = new Schema({ job_title : { type : String, required : true }, job_location : { type : String, }, salary : { type : Number }, applications: [ApplicationSchema], companyId : { type: mongoose.Schema.Types.ObjectId, ref: 'Company' } },{timestamps : true})