Skip to content

Instantly share code, notes, and snippets.

@mgmgpyaesonewin
Created October 31, 2018 07:49
Show Gist options
  • Save mgmgpyaesonewin/76bcce3bea0d17cdb5a5d330098636c7 to your computer and use it in GitHub Desktop.
Save mgmgpyaesonewin/76bcce3bea0d17cdb5a5d330098636c7 to your computer and use it in GitHub Desktop.
delete_booking(code) {
this.get_id_by_code(code, (id) => {
this.$store.dispatch('delete_booking', id)
.then(() => {
this.$toasted.show('Deleted successfully');
this.status = false;
})
.catch(() => this.$toasted.show('Something went wrong'));
});
},
get_id_by_code(code, callback) {
const database = firebase.database();
database.ref('booking')
.orderByChild('booking_code')
.equalTo(code)
.on('value', (snapshot) => {
const ids = Object.keys(snapshot.val());
callback(ids[0]);
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment