在猫鼬的查找查询中检查填充的字段长度

时间:2020-01-14 10:22:54

标签: mongodb mongoose mongodb-query mongoose-schema mongoose-populate

假设以下3个模型:

var CarSchema = new Schema({
  name: {type: String}
});

CarSchema.virtual('parts', {
  ref: 'Part',
  localField: '_id', 
  foreignField: 'car',
  justOne: false,
});

var PartSchema = new Schema({
  name: {type: String},
  otherIds: [{type: Schema.Types.ObjectId, ref: 'Other'}],
  car: [{ type: Schema.Types.ObjectId, ref: 'Car' }]
});

var OtherSchema = new Schema({
  name: {type: String}
});

猫鼬是否可以在查找查询中检查虚拟填充的 零件 字段的长度?

有没有办法忽略猫鼬中的空白数组?

0 个答案:

没有答案