You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/service-module.md
+26-4Lines changed: 26 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,11 +52,17 @@ Each service comes loaded with the following default state:
52
52
{
53
53
ids: [],
54
54
keyedById: {}, // A hash map, keyed by id of each item
55
+
copiesById: {}, // objects cloned with Model.clone()
55
56
currentId:undefined, // The id of the item marked as current
56
57
copy:undefined, // A deep copy of the current item
57
58
idField:'id',
58
59
servicePath:'v1/todos'// The full service path
59
60
autoRemove:false, // Indicates that this service will not automatically remove results missing from subsequent requests.
61
+
enableEvents:true, // Listens to socket.io events when available
62
+
addOnUpsert:false, // Add new records pushed by 'updated/patched' socketio events into store, instead of discarding them
63
+
diffOnPatch:false, // Only send changed data on patch
64
+
skipRequestIfExists:false, // For get action, if the record already exists in store, skip the remote request
65
+
preferUpdate:false, // When true, calling model.save() will do an update instead of a patch.
60
66
replaceItems:false, // When set to true, updates and patches will replace the record in the store instead of merging changes
61
67
paginate:false, // Indicates if pagination is enabled on the Feathers service.
62
68
@@ -86,11 +92,17 @@ The following attributes are available in each service module's state:
86
92
87
93
-`ids {Array}` - an array of plain ids representing the ids that belong to each object in the `keyedById` map.
88
94
-`keyedById {Object}` - a hash map keyed by the id of each item.
95
+
-`copiesById {Object}` - objects cloned with Model.clone()
89
96
-`currentId {Number|String}` - the id of the item marked as current.
90
97
-`copy {Object}` - a deep copy of the current item at the moment it was marked as current. You can make changes to the copy without modifying the `current`. You can then use the `commitCopy` mutation to save the changes as the `current` or `rejectCopy` to revert `copy` to once again match `current`. You may prefer to use the new [clone API]() for [managing multiple copies with model instances](./common-patterns.md#Multiple-Copies).
91
98
-`servicePath {String}` - the full service path, even if you alias the namespace to something else.
92
99
-`modelName {String}` - the key in the $FeathersVuex plugin where the model will be found.
93
-
-`autoRemove {Boolean` - indicates that this service will not automatically remove results missing from subsequent requests. Only use with feathers-rest. Default is false.
100
+
-`autoRemove {Boolean}` - indicates that this service will not automatically remove results missing from subsequent requests. Only use with feathers-rest. Default is false.
101
+
-`enableEvents {Boolean}` - Listens to socket.io events when available
102
+
-`addOnUpsert {Boolean}` - Add new records pushed by 'updated/patched' socketio events into store, instead of discarding them
103
+
-`diffOnPatch {Boolean}` - Only send changed data on patch
104
+
-`skipRequestIfExists {Boolean}` - For get action, if the record already exists in store, skip the remote request
105
+
-`preferUpdate {Boolean}`, // When true, calling model.save() will do an update instead of a patch.
94
106
-`replaceItems {Boolean}` - When set to true, updates and patches will replace the record in the store instead of merging changes. Default is false
95
107
-`idField {String}` - the name of the field that holds each item's id. *Default: `'id'`*
96
108
-`paginate {Boolean}` - Indicates if the service has pagination turned on.
@@ -152,15 +164,21 @@ Removes a single item. `item` can be
152
164
Removes the passed in items or ids from the store.
153
165
-`items {Array}` - An array of ids or of objects with ids that will be removed from the data store.
154
166
155
-
### `setCurrent(state, item)`
167
+
### `setCurrent(state, itemOrId)`
156
168
-`item {Number|String|Object}` - the object with id to be set as the current item, or the id of the object in the store that should become the `current` item. Setting the `current` item or id also create the deep-cloned `copy`.
157
169
158
-
### `commitCopy(state)`
170
+
### `createCopy(state, id)`
171
+
Creates a copy of the record with the passed-in id, stores it in copiesById
172
+
173
+
### `commitCopy(state, id)`
159
174
Saves changes from the `copy` to the `current` item.
160
175
161
-
### `rejectCopy(state)`
176
+
### `rejectCopy(state, id)`
162
177
Re-copies the data from `current` to `copy`, restoring the original copy.
163
178
179
+
### `clearCopy(state, id)`
180
+
Removes the copy from copiesById
181
+
164
182
### `clearCurrent(state)`
165
183
Clears the `current` item, which also clears the copy.
166
184
@@ -170,6 +188,10 @@ Clears the `list`, excepting the `current` item.
170
188
### `clearAll(state)`
171
189
Clears all data from `ids`, `keyedById`, and `currentId`
0 commit comments