Complete Vue.js 2 Web Development_ Practical guide to building end-to-end web development solutions with Vue.js 2

(singke) #1
Integrating with Other Frameworks Chapter 19

The newItem and newSmell variables will temporarily hold the values we entered in the


input boxes; then, the addItem and removeItem methods will publish and remove data


from our database:


data: {
newItem: '',
newSmell: ''
},
methods: {
addItem () {
this.$firebaseRefs.items
.push({
name: this.newItem,
smell: this.newSmell
})
this.newItem = ''
this.newSmell = ''
},
removeItem (key) {
this.$firebaseRefs.items
.child(key).remove()
}
}

If you launch your app now, you'll already be able to add your favorite scents and what to
sniff to find them:


How it works...


Firebase works as a simple key value store. In our case, we are never storing values but
always adding children; you can take a look at what you've created in the Firebase console:

Free download pdf