Issue
Is it possible to compare two arrays in a Firestore query without 'array-contains'?
Something like this:
query = query.where(
"info.currentLocation",
"==",
currentUserBasicInfo.currentLocation
);
info.currentLocation and currentUserBasicInfo.currentLocation are both arrays with mapped values. I can't change the data structure and I already have an 'array-contains' in the query. Because the two arrays have to be identical for this to run, I feel like there has to be a way to compare two arrays without having to use 'array-contains' or 'array-contains-any' or 'IN'.
Any suggestions? Is this possible?
Solution
"array-contains" method has ability to query for elements within arrays. This means you can keep your elements as an array, and easily query for them without having to resort to the map hack.
If you don't want to use this method one alternative could be iterate both arrays until match the values as you need.
However, in this document you can find multiple examples for perform simple and compound queries.
Answered By - Harif Velarde
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.