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;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?