I have the following query in MongoDB
$this->createQueryBuilder()
->field('actor')->in($actorIdArray)
->getQuery()
->execute();
where the field actor is an object reference with annotation
@MongoDB\ReferenceOne(targetDocument="User", simple=true)
which means it will store the object Id instead of the full reference.
When $actorIdArray is an array of id with the form
["5706cb39821b166d3931f34f", "56015f7d4f8bd90b769e6e75"]
the query does not return nothing, which is the expected since the filed actor contains object id.
However, if I build the array this way
[new MongoId("5706cb39821b166d3931f34f"), new MongoId("56015f7d4f8bd90b769e6e75")]
it doesn't work either, which is quite surprising for me.
The log shows the query is made
{ "actor": {"$in":[{"$id":"5706cb39821b166d3931f34f"},{"$id":"56015f7d4f8bd90b769e6e75"}]}}
and I think it should be something like this
{ "actor": {"$in":[ObjectId("5706cb39821b166d3931f34f"),ObjectId("56015f7d4f8bd90b769e6e75"]}}
Not sure if I am doing something wrong, any ideas?