Skip to content

Commit

Permalink
Doc: fix set example in README
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed May 10, 2017
1 parent fc3e986 commit 0c7bd35
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,18 @@ The resulting bound array stored in `vm.items` will be:
]
```

To delete or update an item you can use the `.key` property of a given object:
To delete or update an item you can use the `.key` property of a given object. But keep in mind you have to remove the `.key` attribute of the updated object:

``` js
// Vue instance methods
deleteItem: function (item) {
this.$firebaseRefs.items.child(item['.key']).remove()
},
updateItem: function (item) {
// create a copy of the item
item = {...item}
// remove the .key attribute
delete item['.key']
this.$firebaseRefs.items.child(item['.key']).set(item)
}
```
Expand Down

0 comments on commit 0c7bd35

Please sign in to comment.