Get Firebase items belonging to category

删除回忆录丶 提交于 2019-12-25 04:09:20

问题


In my app I will have items. Each item belongs to at least one category, but multiple categories are possible. I think the following is the best way to structure the data:

items
    item1
         title: apple
         categories:
             food: true
             fruit: true
    item2
         title: spinach
         categories:
             food: true
             veggie: true
    item3
         title: triceratops
         categories:
             dino: true

How do I query Firebase to return all items matching a category? For example: 'food' should return item1 and item2 and 'veggie' item2. I'm using Angular Fire and tried the following which gives me an error:

$firebaseArray ref.child('items').orderByChild("categories/food")

来源:https://stackoverflow.com/questions/32922271/get-firebase-items-belonging-to-category

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!