如何在 mongoose 中使用 model.populate 查询结果过滤 model.find 查询结果?

how to filter model.find query results with model.populate query results in mongoose?

var UserSchema = Schema (
{
    android_id: String,
    rooms: [{ type: Schema.Types.ObjectId, ref: 'Chatrooms'}],
    location: {country: String, state: String, coordinates: { latitude: String, longitude: String}}
});

var RoomSchema = Schema 
({
    Roomname: {type: String},
    ids: {type: Array},
});


Users
    .find({android_id: {$ne: userID}, 'location.state': LocationArray.state, 'location.country': LocationArray.country})
    .populate({
        path: 'rooms',
        match: {'rooms.ids': {$nin: [userID]}},
        select: 'ids'
     })
     .exec(function(err, found) {
     })

我想在我不在 ids 数组中的州和国家/地区找到除我自己以外的所有用户。填充可能吗?

希望对您有所帮助。

Users
.find({android_id: {$ne: userID}, 'location.state': LocationArray.state, 'location.country': LocationArray.country})
.populate({
    path: 'rooms',
    match: {'ids': {$nin: [userID]}},
    select: 'ids'
 })
 .exec(function(err, found) {
 if(found){
      vettings = found.filter(function (doc) {
            return doc.ids;
        });
   }
 })