douqing0713 2016-07-29 05:07
浏览 111
已采纳

Doctrine MongoDB重命名引用字段

I have the following reference in my class:

/**
 * @Expose
 * @Groups({"personal"})
 *
 * @MongoDB\ReferenceMany(targetDocument="AppBundle\Document\Correspondence", cascade={"remove"})
 */
protected $archiveCorrespondences;

And I want to save this reference in my database under the name archive_correspondences But whatever I did, doctrine always keeps it under archiveCorrespondences

I use the following:

  1. php 7
  2. mongodb 3.2
  3. symfony 2.8
  4. doctrine/mongodb-odm : dev-master
  5. doctrine/mongodb-odm-bundle: dev-master

From the doctrine mongodb documentation I did't find any possibilities, like for @Field annotation, where you can specify name. By some reasons I can't rename $archiveCorrespondences to $archive_correspondences in code.

  • 写回答

1条回答 默认 最新

  • doukong1391 2016-07-29 07:56
    关注

    I suggest you to try name property. It should work for ReferenceMany:

    /**
     * @Expose
     * @Groups({"personal"})
     *
     * @MongoDB\ReferenceMany(name="archive_correspondences", targetDocument="AppBundle\Document\Correspondence", cascade={"remove"})
     */
    protected $archiveCorrespondences;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示