猫鼬填充如何将填充子文档加入另一个集合

Mongoose populate how to join populate sub document to another collection

组织者,产品集合,我需要将产品 table 与已发布的用户 ID 和组织者集合以及购买的用户 ID 再次加入用户和组织者。我可以将产品加入用户,但无法将用户加入管理器。

Products.find({})
  .populate({
    path: 'intresteduserIds.userId',
    // Get friends of friends - populate the 'friends' array for every friend
    populate: { path: 'intresteduserIds.user_organizationid' } /* How to join with organizer collection which have organizer id*/
  })
 .populate('product_postedby');

产品架构:

const ProductsObj = new Schema({
  product_title: String,
  product_category: String, 
  product_startDate: Date,
  product_startTime: String,
  product_endDate: Date,
  product_endTime: String,
  product_isPrivateEvent: Boolean, 
  product_desc: String,
  product_postedby: { type: mongoose.Schema.ObjectId, ref: 'User' },
  intresteduserIds: [
    {
      userId: {
        type: mongoose.Schema.ObjectId,
        ref: 'User',
        requested: false
      },
      name: String,
      email: String,
      mobilenumber: String,
      notes: String,
      requirestedDate: Date,
      status: String, 
      eventsList: [
        {
          id: mongoose.Schema.ObjectId,
          name: String
        }
      ],
      intrestedType: String 
    }
  ]
});

包含组织者 ID 的用户架构:

const usersSchema = new Schema({
  user_organizationid: {
    type: mongoose.SchemaTypes.ObjectId,
    required: false,
    index: true,
    ref: 'Oranizations'
  },
  user_firstname: String,
  user_lastname: String,
  user_username: String,
  user_mobilenumber: String,
  user_mobilenumber_code: String,
  user_email: String,
  user_role: {
    type: mongoose.SchemaTypes.ObjectId,
    required: false,
    index: true
  }
});

组织者架构:

const organizerSchema = new Schema({
  org_name: String,
  org_type: String, // organizer,ground , ecommerce seller,
  org_category: String, // corporate company,supplier
  org_logo: String,
  org_address_id: { type: mongoose.Schema.ObjectId, required: false },
  org_stack_exchange_id: String,
  org_created_dated: Date,
  org_updated_date: Date,
  org_activte_status: Boolean,
  user_hashcode: String
});

所以最终我需要:

{
  product:'product info',
  posted_userid:{
  posted_userinfo:'',
  organizerInfo:'join with user if there this information'
  },
  intrestedusers:{
    userid:{
      userinfo:'',
      organizerInfo:'join with user if there this information'
    }
  }
}

我如何在这里找到解决方案?

内部路径必须是 user_organizationid 而不是 intresteduserIds.user_organizationid

Products.find({})
  .populate({
    path: 'intresteduserIds.userId',
    populate: {path: 'user_organizationid' } 
  })
 .populate('product_postedby');