简体   繁体   English

原则MongoDB重命名参考字段

[英]Doctrine MongoDB rename reference field

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 而且我想将此引用以archive_correspondences的名称保存在我的数据库中,但是无论我做什么,学说总是将其保存在archiveCorrespondences下

I use the following: 我使用以下内容:

  1. php 7 PHP的7
  2. mongodb 3.2 mongodb 3.2
  3. symfony 2.8 symfony 2.8
  4. doctrine/mongodb-odm : dev-master 教义/ mongodb-odm:开发大师
  5. doctrine/mongodb-odm-bundle: dev-master 学说/ mongodb-odm-bundle:开发大师

From the doctrine mongodb documentation I did't find any possibilities, like for @Field annotation , where you can specify name. 在mongodb原则文档中,我没有发现任何可能性,例如@Field annotation ,您可以在其中指定名称。 By some reasons I can't rename $archiveCorrespondences to $archive_correspondences in code. 由于某些原因,我无法在代码$archiveCorrespondences重命名$archiveCorrespondences $archive_correspondences

I suggest you to try name property. 我建议您尝试name属性。 It should work for ReferenceMany : 它应该对ReferenceMany起作用:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM