Open jewzaam opened 8 years ago
Actually not possible to use elemMatch, the array referenceIds
is an array of simple types (strings).
I tried rewriting my reference query to hard code the array of values in the array contains query and the association works. But that's only as a PoC that such a query can work if it's rewritten correctly.
The reference query should be $parent._id $in referenceIds, instead of $eq.
That may have been a mistake in my original post. This is not a pressing issue for any ongoing work, the metadata that needed this has been changing. If it comes up again I'll come up with a usable example to post here and test it out with the suggested change.
Entity A has _id. Entity B has referenceIds array with references to A._id.
Entity A has reference to B with
But this is rewritten by query planner to:
I'll look at writing as elemMatch as the array contains syntax doesn't support referencing fields, only supports values (per documentation at least: https://jewzaam.gitbooks.io/lightblue-specifications/content/language_specification/query.html)