Skip to content

Commit e486c85

Browse files
committed
Fix create action documentation Fixes #230
1 parent ab1b9f9 commit e486c85

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

docs/service-module.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,23 @@ store.dispatch('todos/get', [1, params])
259259

260260
Make sure your returned records have a unique field that matches the `idField` option for the service plugin.
261261

262-
### `create(data)`
263-
Create one or multiple records.
264-
- `data {Object|Array}` - if an object is provided, a single record will be created. If an array of objects is provided, multiple records will be created.
262+
### `create(data|ParamArray)`
263+
264+
Create one or multiple records. Note that the method is overloaded to accept two types of arguments. If you want a consistent interface for creating single or multiple records, use the array syntax, described below. Creating multiple records requires using the `paramArray` syntax.
265+
266+
- `data {Object|ParamArray}` - if an object is provided, a single record will be created.
265267

266268
```js
267269
let newTodo = {description: 'write good tests'}
268270
store.dispatch('todos/create', newTodo)
269271
```
270272

273+
- `data {ParamArray}` - if an array is provided, it is assumed to have this structure:
274+
275+
- `ParamArray {Array}` - array containing the two parameters that Feathers' `service.create` method accepts.
276+
- `data {Object|Array}` - the data to create. Providing an object creates a single record. Providing an array of objects creates multiple records.
277+
- `params {Object}` - optional - an object containing a `query` object. Can be useful in rare situations.
278+
271279
Make sure your returned records have a unique field that matches the `idField` option for the service plugin.
272280

273281
### `update(paramArray)`

0 commit comments

Comments
 (0)