Skip to content

Instantly share code, notes, and snippets.

@ojengwa
Last active March 9, 2017 16:55
Show Gist options
  • Save ojengwa/543df924329c55aadfad16562bdbeff9 to your computer and use it in GitHub Desktop.
Save ojengwa/543df924329c55aadfad16562bdbeff9 to your computer and use it in GitHub Desktop.
let unassigned = realtime.unassigned.child(attrs.body.order_id)
let assigned = realtime.assigned.child(attrs.body.order_id)
unassigned.ref.once('value', (data) => {
data = data.val()
data['status'] = 'assigned'
assigned.set(data, (error) => {
if (!error) {
let champion_ref = realtime.champions.child(attrs.body.champion_id + '/assigned/' + attrs.body.order_id)
champion_ref.set(data, (error) => {
if (!error){ unassigned.remove()}
})
}
})
}, (err) => {
console.log(err, '<= firebase error')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment