Last active
July 26, 2017 15:21
-
-
Save codediodeio/6c561f6f7cdd79ccd4b46247d0d4fb75 to your computer and use it in GitHub Desktop.
Composite Key Pattern in Firebase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
createData() { | |
const data = { | |
name: 'Crane', | |
family: 'bird', | |
weight: 10, | |
endangered: false, | |
// composite keys | |
endangered_family: 'false_bird', | |
endangered_weight: 'false_10', | |
family_weight: 'bird_10', | |
endangered_family_weight: 'false_bird_10' | |
} | |
this.db.list('/animals').push(data) | |
} | |
getData() { | |
this.db.list('/animals', { | |
query: { | |
orderByChild: 'endangered_family_weight', | |
equalTo: 'bird_10_false' | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment