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
The following example creates a User class and registers it with the new `makeServicePlugin` utility function.
122
+
The following example creates a User class and registers it with the new `makeServicePlugin` utility function. This same file is also a great place to add your service-level hooks, so they're shown, too.
idField:'_id', // The field in each record that will contain the id
192
-
nameStyle:'path', // Use the full service path as the Vuex module name, instead of just the last section
193
-
namespace:'custom-namespace', // Customize the Vuex module name. Overrides nameStyle.
194
-
debug:true, // Enable some logging for debugging
195
-
autoRemove:true, // Automatically remove records missing from responses (only use with feathers-rest)
196
-
enableEvents:false, // Turn off socket event listeners. It's true by default
197
-
addOnUpsert:true, // Add new records pushed by 'updated/patched' socketio events into store, instead of discarding them. It's false by default
198
-
replaceItems:true, // If true, updates & patches replace the record in the store. Default is false, which merges in changes
199
-
skipRequestIfExists:true, // For get action, if the record already exists in store, skip the remote request. It's false by default
200
-
modelName:'OldTask'// Default modelName would have been 'Task'
201
-
})
202
-
203
-
// Add custom state, getters, mutations, or actions, if needed. See example in another section, below.
204
-
service('things', {
205
-
state: {},
206
-
getters: {},
207
-
mutations: {},
208
-
actions: {}
209
-
})
210
-
211
-
// Setup a service with defaults for Model instances
212
-
service('manufacturers', {
213
-
instanceDefaults: {
214
-
name:''
215
-
}
216
-
})
217
-
// Setup a service with light-weight relational data
218
-
service('models', {
219
-
instanceDefaults: {
220
-
name:'',
221
-
manufacturerId:'',
222
-
manufacturer:'Manufacturer'// Refers to data (populated on the server) that gets put in the `manufacturers` vuex store.
223
-
}
224
-
})
225
-
226
-
// Setup the auth plugin.
227
-
auth({ userService:'users' })
228
-
]
221
+
state: {},
222
+
mutations: {},
223
+
actions: {},
224
+
plugins: [...servicePlugins, auth]
229
225
})
226
+
230
227
```
231
228
232
229
The new `feathers-vuex` API is more Vuex-like. All of the functionality remains the same, but it is no longer configured like a FeathersJS plugin. While the previous functionality was nice for prototyping, it didn't work well in SSR scenarios, like with Nuxt.
@@ -253,15 +250,15 @@ const defaultOptions = {
253
250
254
251
Each service module can also be individually configured.
255
252
256
-
## The Vuex modules
253
+
## The Vuex Plugins
257
254
258
-
There are two modules included:
255
+
There are two plugins included:
259
256
260
-
1. The [Service module](./service-module.md) adds a Vuex store for new services.
261
-
2. The [Auth module](./auth-module.md) sets up the Vuex store for authentication / logout.
257
+
1. The [Service Plugin](./service-plugin.md) adds a Vuex store for new services.
258
+
2. The [Auth Plugin](./auth-plugin.md) sets up the Vuex store for authentication / logout.
262
259
263
260
## License
264
261
265
-
Copyright (c) Forever and Ever, or at least the current year.
262
+
Copyright (c) Forever, or at least the current year.
Copy file name to clipboardExpand all lines: docs/common-patterns.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,11 +12,11 @@ You can set `debug: true` in the options to enable some logging to assist with d
12
12
13
13
## Use the `<FeathersVuexFind>` and `<FeathersVuexGet>` components
14
14
15
-
Using the new `<FeathersVuexFind>` and `<FeathersVuexGet>` components provides concise access to the best features of `feathers-vuex`, including live queries, reactive lists, custom pagination tracking per component, and fall-through cacheing of local data in the Vuex store. Check out the [Renderless Data Components](./components.md) docs for more details.
15
+
Using the new `<FeathersVuexFind>` and `<FeathersVuexGet>` components provides concise access to the best features of `feathers-vuex`, including live queries, reactive lists, custom pagination tracking per component, and fall-through cacheing of local data in the Vuex store. Check out the [Renderless Data Components](./components.html) docs for more details.
16
16
17
17
## Use the `makeFindMixin` and `makeGetMixin` utilities
18
18
19
-
The mixin utilities provide the same functionality as the components, but with more power and flexibility. Check out the [Mixin docs](./mixins.md) for more details.
19
+
The mixin utilities provide the same functionality as the components, but with more power and flexibility. Check out the [Mixin docs](./mixins.html) for more details.
20
20
21
21
## Working with TypeScript
22
22
@@ -28,7 +28,7 @@ The best solution is to simply refresh to clear memory. The alternative to refr
28
28
29
29
## Accessing the store from hooks
30
30
31
-
Because the service's Model [is available](./service-module.md#The-FeathersClient-Service) at `service.FeathersVuexModel`, you can access the store inside hooks. This is especially handy if you have some custom attributes in a paginated server response.
31
+
Because the service's Model [is available](./service-plugin.html#The-FeathersClient-Service) at `service.FeathersVuexModel`, you can access the store inside hooks. This is especially handy if you have some custom attributes in a paginated server response.
32
32
33
33
As an example, this `speeding-tickets` service has a `summary` attribute that comes back in the response. We can
34
34
@@ -73,7 +73,7 @@ Sometimes your server response may contain more attributes than just database re
73
73
74
74
Depending on what you need to do, you may be able to solve this by [accessing the store from hooks](#Accessing-the-store-from-hooks). But that solution won't handle a scenario where you need the response data to be already populated in the store.
75
75
76
-
If you need the response data to already be in the store, you can use the [`afterFind` action](./service-module.md#afterFind-response). Here's what this looks like:
76
+
If you need the response data to already be in the store, you can use the [`afterFind` action](./service-plugin.html#afterFind-response). Here's what this looks like:
77
77
78
78
```js
79
79
importfeathersVuexfrom'feathers-vuex'
@@ -289,7 +289,7 @@ In summary, you can plan on individual records in the action response data to be
289
289
290
290
## Basic Data Modeling with `instanceDefaults`
291
291
292
-
See the [instanceDefaults API](./model-classes.md#instanceDefaults)
292
+
See the [instanceDefaults API](./model-classes.html#instanceDefaults)
293
293
294
294
## Model-Specific Computed Properties
295
295
@@ -371,7 +371,7 @@ instanceDefaults: {
371
371
}
372
372
```
373
373
374
-
When this record is instantiated, the `user` attribute will first be turned into a User [model instance](./model-classes.md), stored properly in the `/users` store. The `todo.user` attribute will be a reference to that user. No more duplicate data! Here's an example of how to set this up. The following example specifies that Todo instances can have a `user` attribute that contains a `User` Model instance:
374
+
When this record is instantiated, the `user` attribute will first be turned into a User [model instance](./model-classes.html), stored properly in the `/users` store. The `todo.user` attribute will be a reference to that user. No more duplicate data! Here's an example of how to set this up. The following example specifies that Todo instances can have a `user` attribute that contains a `User` Model instance:
Copy file name to clipboardExpand all lines: docs/model-classes.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
---
2
-
title: Models & Instances API
2
+
title: Data Modeling
3
3
---
4
4
5
5
<!-- markdownlint-disable MD002 MD033 MD041 -->
@@ -17,7 +17,7 @@ The following attributes are available on each model:
17
17
18
18
### Model.find(params)
19
19
20
-
Model classes have a `find` method, which is a proxy to the [`find` action](./service-module.md#find-params). <Badgetext="1.7.0+" />
20
+
Model classes have a `find` method, which is a proxy to the [`find` action](./service-plugin.html#find-params). <Badgetext="1.7.0+" />
21
21
22
22
```js
23
23
// In your Vue component
@@ -29,7 +29,7 @@ created () {
29
29
30
30
### Model.findInStore(params)
31
31
32
-
Model classes have a `findInStore` method, which is a proxy to the [`find` getter](./service-module.md#Service-Getters). <Badgetext="1.7.0+" />
32
+
Model classes have a `findInStore` method, which is a proxy to the [`find` getter](./service-plugin.html#Service-Getters). <Badgetext="1.7.0+" />
33
33
34
34
```js
35
35
// In your Vue component
@@ -41,7 +41,7 @@ created () {
41
41
42
42
### Model.get(id, params)
43
43
44
-
Model classes have a `get` method, which is a proxy to the [`get` action](./service-module.md#get-id-or-get-id-params). <Badgetext="1.7.0+" />Notice that the signature is more Feathers-like, and doesn't require using an array to passing both id and params.
44
+
Model classes have a `get` method, which is a proxy to the [`get` action](./service-plugin.html#get-id-or-get-id-params). <Badgetext="1.7.0+" />Notice that the signature is more Feathers-like, and doesn't require using an array to passing both id and params.
45
45
46
46
```js
47
47
// In your Vue component
@@ -53,7 +53,7 @@ created () {
53
53
54
54
### Model.getFromStore(id, params)
55
55
56
-
Model classes have a `getFromStore` method, which is a proxy to the [`get` getter](./service-module.md#Service-Getters). <Badgetext="1.7.0+" /> Notice that the signature is more Feathers-like, and doesn't require using an array to passing both id and params.
56
+
Model classes have a `getFromStore` method, which is a proxy to the [`get` getter](./service-plugin.html#Service-Getters). <Badgetext="1.7.0+" /> Notice that the signature is more Feathers-like, and doesn't require using an array to passing both id and params.
0 commit comments