@@ -290,11 +290,12 @@ store.dispatch('todos/create', newTodo)
290
290
```
291
291
292
292
293
- #### ` update([id, data, params] ) `
293
+ #### ` update(paramArray ) `
294
294
Update (overwrite) a record.
295
- - ` id {Number|String} ` - the ` id ` of the existing record being requested from the API server.
296
- - ` data {Object} ` - the data that will overwrite the existing record
297
- - ` params {Object} ` - An object containing a ` query ` object.
295
+ - ` paramArray {Array} ` - array containing the three parameters update takes.
296
+ - ` id {Number|String} ` - the ` id ` of the existing record being requested from the API server.
297
+ - ` data {Object} ` - the data that will overwrite the existing record
298
+ - ` params {Object} ` - An object containing a ` query ` object.
298
299
299
300
``` js
300
301
let data = {id: 5 , description: ' write your tests' , completed: true }
@@ -303,11 +304,26 @@ let params = {}
303
304
store .dispatch (' todos/update' , [1 , data, params])
304
305
```
305
306
306
- #### ` patch([id, data, params]) `
307
+ Alternatively in a Vue component
308
+ ```
309
+ import { mapActions } from 'vuex'
310
+ export default {
311
+ methods: {
312
+ ...mapActions('todos', [ 'update' ]),
313
+ addTodo () {
314
+ let data = {id: 5, description: 'write your tests', completed: true}
315
+ this.update([1, data, {}])
316
+ }
317
+ }
318
+ }
319
+ ```
320
+
321
+ #### ` patch(paramArray) `
307
322
Patch (merge in changes) one or more records
308
- - ` id {Number|String} ` - the ` id ` of the existing record being requested from the API server.
309
- - ` data {Object} ` - the data that will be merged into the existing record
310
- - ` params {Object} ` - An object containing a ` query ` object.
323
+ - ` paramArray {Array} ` - array containing the three parameters patch takes.
324
+ - ` id {Number|String} ` - the ` id ` of the existing record being requested from the API server.
325
+ - ` data {Object} ` - the data that will be merged into the existing record
326
+ - ` params {Object} ` - An object containing a ` query ` object.
311
327
312
328
``` js
313
329
let data = {description: ' write your tests' , completed: true }
0 commit comments