如何选择集合中所有其他文档的数组属性中不包含的文档 ID?

问题描述 投票:0回答:0

我收集了以下形状的文件:

const categorySchema = new Schema<ICategory>({
  title: { type: String, required: true },  
  children: [{ type: Types.ObjectId, ref: categoryModelName }],  
});

我想获取集合中所有其他文档的子数组属性中未包含的所有文档 ID。如果可能,如何编写这样的查询?

mongodb mongodb-query aggregation-framework
© www.soinside.com 2019 - 2024. All rights reserved.