在查找阶段将键数组匹配为localFields

时间:2019-02-05 07:07:59

标签: mongodb aggregation-framework

我在该集合内有一个名为construction的集合,我有一个名为keyContact的对象数组,它引用了用户集合,我需要根据ID

向该对象数组添加用户的名字和姓氏

{
    keyContact:[
      {
        "_id":ObjectId("288888564154342163f123d")
      },
      {
        "_id":ObjectId("2454654564154342163f123d")
      },
      {
        "_id":ObjectId("24567564154342167654333")
      }
    ]
}

我需要将用户的名字和姓氏添加到该对象数组中

{ keyContact:[
  {
    "_id":ObjectId("288888564154342163f123d"),
    "firstName":"warren",
    "lastName":"Buffet"
  },
  {
    "_id":ObjectId("2454654564154342163f123d"),
    "firstName":"Mark",
    "lastName":"Wahlberg"
  },
  {
    "_id":ObjectId("24567564154342167654333"),
    "firstName":"quito",
    "lastName":"Paul"
  }
]}

0 个答案:

没有答案