填充后猫鼬更改填充的字段名称

Nit*_*its 5 mongoose

在猫鼬中,我在现场使用填充。填充后需要更改字段名称。是否可以?

我在 company_id 上填充。它向我显示 company_id: Object 但我需要将其名称更改为 company:Object。

    this.model(companySessionModelName)
    .find(
          {
            "company_session.end_date":{$lt:arg_date},
            "company_session.status":"active"
          },
          {
            "company_id":1,
            "company_session.$":1
          }
        )
.populate("company_id","name")                                            
.exec(function(err, _s_user) {
         if(err){
           cb(err);
         }else{
            cb(null,_s_user);
         }   });
Run Code Online (Sandbox Code Playgroud)

输出:

[
            {
                "_id": "5a829132a83f321e380cd17f",
                "company_id": {
                    "_id": "5a7ad080f8c88a231113676f",
                    "name": "Stephania Rath"
                },
                "company_session": [
                    {
                        "start_date": "2018-02-14T00:00:00.000Z",
                        "end_date": "2018-02-16T00:00:00.000Z",
                        "_id": "5a829132a83f321e380cd180",
                        "status": "active"
                    }
                ]
            }
        ]
Run Code Online (Sandbox Code Playgroud)

异常输出:

[
            {
                "_id": "5a829132a83f321e380cd17f",
                "company": {
                    "_id": "5a7ad080f8c88a231113676f",
                    "name": "Stephania Rath"
                },
                "company_session": [
                    {
                        "start_date": "2018-02-14T00:00:00.000Z",
                        "end_date": "2018-02-16T00:00:00.000Z",
                        "_id": "5a829132a83f321e380cd180",
                        "status": "active"
                    }
                ]
            }
        ]
Run Code Online (Sandbox Code Playgroud)