Skip to content

Commit 595a837

Browse files
committed
update getting-started global configuration
1 parent 2cddab6 commit 595a837

File tree

3 files changed

+53
-32
lines changed

3 files changed

+53
-32
lines changed

.vscode/settings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
"search.exclude": {
88
"lib/**": true,
99
"**/node_modules": true,
10-
"**/bower_components": true
10+
"**/bower_components": true,
11+
"**/yarn.lock": true
1112
},
1213
"workbench.colorCustomizations": {
1314
"activityBar.background": "#2B3011",
1415
"titleBar.activeBackground": "#3C4418",
1516
"titleBar.activeForeground": "#FAFBF4"
1617
}
17-
}
18+
}

docs/getting-started.md

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -269,22 +269,42 @@ The following default options are available for configuration:
269269

270270
```js
271271
const defaultOptions = {
272-
autoRemove: false, // Automatically remove records missing from responses (only use with feathers-rest)
273-
addOnUpsert: false, // Add new records pushed by 'updated/patched' socketio events into store, instead of discarding them
274-
enableEvents: true, // Listens to socket.io events when available. See the `handleEvents` API for more details
275-
idField: 'id', // The field in each record that will contain the id
276-
tempIdField: '__id',
277-
debug: false, // Set to true to enable logging messages.
278-
keepCopiesInStore: false, // Set to true to store cloned copies in the store instead of on the Model.
279-
nameStyle: 'short', // Determines the source of the module name. 'short', 'path', or 'explicit'
280-
paramsForServer: [], // Custom query operators that are ignored in the find getter, but will pass through to the server.
281-
preferUpdate: false, // When true, calling model.save() will do an update instead of a patch.
282-
replaceItems: false, // Instad of merging in changes in the store, replace the entire record.
272+
// configured globally
283273
serverAlias: 'api',
284-
skipRequestIfExists: false, // For get action, if the record already exists in store, skip the remote request
285-
whitelist: [] // Custom query operators that will be allowed in the find getter.
274+
keepCopiesInStore: false,
275+
paramsForServer: [],
276+
whitelist: []
277+
278+
// also configurable per service
279+
idField: 'id',
280+
tempIdField: '__id',
281+
debug: false,
282+
addOnUpsert: false,
283+
autoRemove: false,
284+
enableEvents: true,
285+
preferUpdate: false,
286+
replaceItems: false,
287+
skipRequestIfExists: false,
288+
nameStyle: 'short',
286289
}
287290
```
291+
- `serverAlias` - **Default:** `api` - Models are keyed by `serverAlias`. Access the `$FeathersVuex` Plugin and its models in your components by `this.$FeathersVuex.api.${Model}`
292+
- `keepCopiesInStore` - **Default:** `false` - Set to true to store cloned copies in the store instead of on the Model. <Badge text="deprecated" type="warning" />
293+
- `paramsForServer {Array}` - **Default:** `[]` - Custom query operators that are ignored in the find getter, but will pass through to the server.
294+
- `whitelist {Array}` - **Default:** `[]` - Custom query operators that will be allowed in the find getter.
295+
296+
- `idField {String}` - **Default:** `'id'` - The field in each record that will contain the id
297+
- `tempIdField {Boolean}` - **Default:** `'__id'` - The field in each temporary record that contains the id
298+
- `debug {Boolean}` - **Default:** `false` - Enable some logging for debugging
299+
- `addOnUpsert {Boolean}` - **Default:** `false` - If `true` add new records pushed by 'updated/patched' socketio events into store, instead of discarding them.
300+
- `autoRemove {Boolean}` - **Default:** `false` - If `true` automatically remove records missing from responses (only use with feathers-rest)
301+
- `enableEvents {Boolean}` - **Default:** `true` - If `false` socket event listeners will be turned off. See the services [handleEvents API](/service-plugin.html#configuration)
302+
- `preferUpdate {Boolean}` - **Default:** `false` - If `true`, calling `model.save()` will do an `update` instead of a `patch`.
303+
- `replaceItems {Boolean}` - **Default:** `false` - If `true`, updates & patches replace the record in the store. Default is false, which merges in changes.
304+
- `skipRequestIfExists {Boolean}` - **Default:** `false` - For get action, if `true` the record already exists in store, skip the remote request.
305+
- `nameStyle {'short'|'path'}` - **Default:** `'short'` - Use the full service path as the Vuex module name, instead of just the last section.
306+
307+
Also see the [Configs per Service](/service-plugin.html#configuration)
288308

289309
### Note about feathers-reactive
290310

docs/service-plugin.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,24 @@ const servicePlugin = makeServicePlugin({
2525
// necesarry
2626
Model,
2727
service: feathersClient.service(servicePath),
28-
29-
// optional
30-
servicePath,
28+
29+
// optional and configurable by global config
3130
idField: 'id',
3231
tempIdField: '__id',
33-
servicePath: '',
34-
nameStyle: 'short',
3532
debug: false,
33+
addOnUpsert: false,
3634
autoRemove: false,
37-
preferUpdate: false,
3835
enableEvents: true,
39-
addOnUpsert: false,
36+
preferUpdate: false,
4037
replaceItems: false,
4138
skipRequestIfExists: false,
42-
39+
nameStyle: 'short',
40+
41+
// optional and only configurable per service
42+
servicePath: '',
4343
namespace: null,
4444
modelName: 'User',
45-
45+
4646
instanceDefaults: () => ({}),
4747
setupInstance: instance => instance,
4848
handleEvents: {
@@ -51,12 +51,12 @@ const servicePlugin = makeServicePlugin({
5151
updated: (item, { model, models }) => options.enableEvents,
5252
removed: (item, { model, models }) => options.enableEvents
5353
},
54-
54+
5555
state: {},
5656
getters: {},
5757
mutations: {},
5858
actions: {},
59-
59+
6060
//...
6161
});
6262
```
@@ -65,12 +65,12 @@ The following options can also be configured in [Global Configuration](getting-s
6565
- `idField {String}` - **Default:** `'id'` - The field in each record that will contain the id
6666
- `tempIdField {Boolean}` - **Default:** `'__id'` - The field in each temporary record that contains the id
6767
- `debug {Boolean}` - **Default:** `false` - Enable some logging for debugging
68-
- `autoRemove {Boolean}` - **Default:** `false` - If `true` automatically remove records missing from responses (only use with feathers-rest)
6968
- `addOnUpsert {Boolean}` - **Default:** `false` - If `true` add new records pushed by 'updated/patched' socketio events into store, instead of discarding them.
69+
- `autoRemove {Boolean}` - **Default:** `false` - If `true` automatically remove records missing from responses (only use with feathers-rest)
70+
- `enableEvents {Boolean}` - **Default:** `true` - If `false` socket event listeners will be turned off
71+
- `preferUpdate {Boolean}` - **Default:** `false` - If `true`, calling `model.save()` will do an `update` instead of a `patch`.
7072
- `replaceItems {Boolean}` - **Default:** `false` - If `true`, updates & patches replace the record in the store. Default is false, which merges in changes.
7173
- `skipRequestIfExists {Boolean}` - **Default:** `false` - For get action, if `true` the record already exists in store, skip the remote request.
72-
- `preferUpdate {Boolean}` - **Default:** `false` - If `true`, calling `model.save()` will do an `update` instead of a `patch`.
73-
- `enableEvents {Boolean}` - **Default:** `true` - If `false` socket event listeners will be turned off
7474
- `nameStyle {'short'|'path'}` - **Default:** `'short'` - Use the full service path as the Vuex module name, instead of just the last section.
7575

7676
The following options can only configured individually per service plugin
@@ -85,7 +85,7 @@ The following options can only configured individually per service plugin
8585
- `patched {Function}` - **Default:** `(item, { model, models }) => options.enableEvents` - handle `created` events, return true to update in the store
8686
- `updated {Function}` - **Default:** `(item, { model, models }) => options.enableEvents` - handle `created` events, return true to update in the store
8787
- `removed {Function}` - **Default:** `(item, { model, models }) => options.enableEvents` - handle `removed` events, return true to remove from the store
88-
88+
8989
- `state {Object}` - **Default:**: `null` - Pass custom `states` to the service plugin or modify existing ones
9090
- `getters {Object}` - **Default:** `null` - Pass custom `getters` to the service plugin or modify existing ones
9191
- `mutations {Object}` - **Default:** `null` - Pass custom `mutations` to the service plugin or modify existing ones
@@ -115,7 +115,7 @@ Each service comes loaded with the following default state:
115115
idField: 'id',
116116
keyedById: {},
117117
tempsById: {},
118-
tempsByNewId: {},
118+
tempsByNewId: {},
119119
pagination: {
120120
defaultLimit: null,
121121
defaultSkip: null
@@ -124,7 +124,7 @@ Each service comes loaded with the following default state:
124124
modelName: 'Todo',
125125
autoRemove: false,
126126
replaceItems: false,
127-
127+
128128
pagination: {
129129
ids: []
130130
limit: 0

0 commit comments

Comments
 (0)