如何使用模型的内部属性(mongoose-paginate-v2中对象的引用)查询模型

如何使用模型的内部属性(mongoose-paginate-v2中对象的引用)查询模型,mongoose,mongoose-plugins,Mongoose,Mongoose Plugins,我有两个模型Account和Customer,Account模式如下所示: const accountSchema = new Schema( { nuban: { type: String, unique: true }, balance: { type: mongoose.Schema.Types.ObjectId, ref: 'Balance' }, customer: { ty

我有两个模型Account和Customer,Account模式如下所示:

    const accountSchema = new Schema(
  {
    nuban: {
      type: String,
      unique: true
    },
    balance: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'Balance'
    },
    customer: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'Customer'
    },
  },
  {
    timestamps: { createdAt: 'created_at', updatedAt: 'last_updated' }
  }
);
客户模型是Account Model的一个属性,其模式如下:

const customerSchema = new Schema({
  name: {
    type: String
  },
  email: [{
    type: String,
    maxlength: 50
  }],
  phone: [{
    type: String,
    maxlength: 50
  }],
}, {
  timestamps: { createdAt: 'created_at', updatedAt: 'last_updated' }
})
使用
mongoose-paginate-v2
如果客户名称(customer.name)等于“特朗普”,即使客户是一个引用对象,如何获得分页帐户

我尝试了以下方法:

const options = {
      populate:[
        { path: 'customer', model: 'Customer', select: 'name _id', match: { name: { 
   $regex:'Trump', $options: 'i' } } }
      ],
       page, limit, sort: { last_updated: -1 }
    }

const accounts = await this.paginate({}, options)
但它提供了数据库中的所有帐户,同时也省略了customer对象的customer属性。name不是值为null的“Trump”

如何获得只包含名称(customer.name)为“trump”的客户的帐户的分页结果(doc)