Mongoose find all documents where array.length is greater than 0 & sort the data
问题 I am using mongoose to perform CRUD operation on MongoDB. This is how my schema looks. var EmployeeSchema = new Schema({ name: String, description: { type: String, default: 'No description' }, departments: [] }); Each employee can belong to multiple department. Departments array will look like [1,2,3]. In this case departments.length = 3. If the employee does not belong to any department, the departments.length will be equal to 0. I need to find all employee where EmployeeSchema.departments