Skip to content

Instantly share code, notes, and snippets.

@codediodeio
Last active July 26, 2017 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codediodeio/6c561f6f7cdd79ccd4b46247d0d4fb75 to your computer and use it in GitHub Desktop.
Save codediodeio/6c561f6f7cdd79ccd4b46247d0d4fb75 to your computer and use it in GitHub Desktop.
Composite Key Pattern in Firebase
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