I want to find some documents from my mongo database, and I use the function: FindBy () unfortunately, this function has no field selection arguments, for example, the native mongodb driver with the function: find (). Does anyone know how to choose special fields in the Mondobb doctrine? Thanks
You will need to use QueryBuilder with a select statement:
select
$result = $dm->createQueryBuilder('User')->select('field1', 'field2')->field('field3')->equals('somevalue')->getQuery()->execute();
http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/query-builder-api.html
findBy supports statements, but the supplied argument must be an array with the field name as the key for the first dimension, for example:
$results = $yourRepositoryInstance->findBy(['somefield' => ['$in' => $arrayOfValues]]);