0

My data in firebase is structured like this (I know it could be structured better.) :

posts
  -Kjas0273471234
    title: "Post Title"
    desc: "Post Description"
    tags: [tag1, tag3, tag8]
  -Kjas0281386734
    title: "Post Title"
    desc: "Post Description"
    tags: [tag1, tag7]

How can I get all posts that have tag1? I want to display the information about all the posts with the tag tag1. I have tried just selecting all posts, then from there checking if they have the tag, but this is not very good for performance to have to download all the posts.

Kheva Mann
  • 319
  • 4
  • 16
  • Short answer: you can't. Long answer: see [this question](http://stackoverflow.com/q/41172471/6680611) and substitute `tags` for `keywords`. (Also, Firebase does not store arrays; it'll be converted to `"tags": { "0": "tag1", "1": "tag3", "2": "tag8" }`, etc.) – cartant Jan 07 '17 at 07:16
  • 1
    Possible duplicate of [Firebase database strucutre](http://stackoverflow.com/questions/41172471/firebase-database-strucutre) – cartant Jan 07 '17 at 07:16
  • Also see http://stackoverflow.com/questions/40656589/firebase-query-if-child-of-child-contains-a-value – Frank van Puffelen Jan 07 '17 at 16:31

0 Answers0