From 97318f11195d5bf110049ee4a483e193d7f2e748 Mon Sep 17 00:00:00 2001 From: sadick254 Date: Sat, 5 Nov 2016 08:35:11 +0300 Subject: [PATCH 1/2] Adding deletion and update info --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 13d90574..7d7b71d1 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,20 @@ The resulting bound array stored in `vm.items` will be: } ] ``` +Therefore to delete or update an item: first you have to obtain a reference to the '.key' property or the item object. In your Vue instance you could add + ``` js + //pass '.key' property from html + vm.deleteItem = function(key) { + var ref = db.ref('items/'+key) + ref.remove() + } + //pass in item object from html + vm.updateItem = function(item) { + var key = item['.key'] + var ref = db.ref('items/'+key) + ref.set(item) + } + ``` ## Contributing From fd34968080dc1c916ca5127d827201f2d613e618 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Sat, 5 Nov 2016 17:26:32 +0100 Subject: [PATCH 2/2] Fix README code style and comments Closes #43 --- README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 7d7b71d1..9ab79475 100644 --- a/README.md +++ b/README.md @@ -154,20 +154,20 @@ The resulting bound array stored in `vm.items` will be: } ] ``` -Therefore to delete or update an item: first you have to obtain a reference to the '.key' property or the item object. In your Vue instance you could add - ``` js - //pass '.key' property from html - vm.deleteItem = function(key) { - var ref = db.ref('items/'+key) - ref.remove() - } - //pass in item object from html - vm.updateItem = function(item) { - var key = item['.key'] - var ref = db.ref('items/'+key) - ref.set(item) + +To delete or update an item you can use the `.key` property of a given object: + +``` js + // Vue instance methods + deleteItem: function (item) { + this.$firebaseRefs.items.child(item['.key']).remove() + }, + updateItem: function (item) { + this.$firebaseRefs.items.child(item['.key']).set(item) } - ``` +``` + +You can check the full example at [examples/todo-app](examples/todo-app/index.html). ## Contributing