I have the following user document config in yml mapping with id field as MongoId. I have use case that is required me to use aggregation builder to project data. When the result is available, the document _id will return as MongoId Object.
Does anyone know how to project the _id field in the to return string instead of MongoId?
Document mapping in YML:
UserDocument:
fields:
_id:
id: true
username:
type: string
Aggregation Query:
$ab = $dm->createAggregationBuilder('UserDocument');
$ab->project()
->includeFields([
'username',
]);
$users = $ab->execute();
Result:
{
"_id": [],
"username": "user"
}
Thanks