Skip to content

Commit 0c7bd35

Browse files
committed
Doc: fix set example in README
1 parent fc3e986 commit 0c7bd35

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,18 @@ The resulting bound array stored in `vm.items` will be:
176176
]
177177
```
178178

179-
To delete or update an item you can use the `.key` property of a given object:
179+
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:
180180

181181
``` js
182182
// Vue instance methods
183183
deleteItem: function (item) {
184184
this.$firebaseRefs.items.child(item['.key']).remove()
185185
},
186186
updateItem: function (item) {
187+
// create a copy of the item
188+
item = {...item}
189+
// remove the .key attribute
190+
delete item['.key']
187191
this.$firebaseRefs.items.child(item['.key']).set(item)
188192
}
189193
```

0 commit comments

Comments
 (0)