[英]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: 我使用以下内容:
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.