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")