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.

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;