I'd like to query some posts in firestore based on tags user entered. Whenever a user submits a post, the user also submits tags along with it. My current data structure looks like this:
postId: {
tags: {
"firebase": true,
"angular": true,
"cats": false
}
}
However, the above data structure makes it hard to query. I cannot use the arrayContainsAny function and would have to download all of the tags and check if each tag/key is true then return the posts. However, if I store the tags as an array:
postId: {
tags: {
0: "firebase",
1: "angular",
2: "cats"
}
}
I could use the firestore func like postsCollection.whereField("tags", arrayContainsAny: tagsArray) for fast querying.
Is it more efficient or scalable to store tags as an array?
Thanks in advance!