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: README.md
+63-1Lines changed: 63 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -261,6 +261,8 @@ let params = {query: {completed: true}}
261
261
store.dispatch('todos/find', params)
262
262
```
263
263
264
+
See the section about pagination, below, for more information that is applicable to the `find` action.
265
+
264
266
#### `get(id)` or `get([id, params])`
265
267
Query a single record from the server & add to Vuex store
266
268
-`id {Number|String}` - the `id` of the record being requested from the API server.
@@ -318,6 +320,66 @@ Remove/delete the record with the given `id`.
318
320
store.dispatch('todos/remove', 1)
319
321
```
320
322
323
+
## Querying with Find & Pagination
324
+
Both the `find` action and the `find` getter support pagination. There are differences in how they work.
325
+
326
+
### The `find` action
327
+
328
+
The `find` action queries data from the remote server. It returns a promise that resolves to the response from the server. The presence of pagination data will be determined by the server.
329
+
330
+
`[email protected]` can store pagination data on a per-query basis. The `pagination` store attribute maps queries to their most-recent pagination data. It's an empty object by default, but after performing a single query (with pagination in the response), it will have a `default` property. This property stores pagination information for the query. Here's what it will look like:
331
+
332
+
**`params = { query: {} }`**
333
+
```js
334
+
{
335
+
pagination: {
336
+
default: {
337
+
query: {}, // Same as params.query
338
+
ids: [0, 1, 2], // the ids in the store for the records that were returned from the server
339
+
limit:0, // the response.limit
340
+
skip:0, // the response.skip
341
+
total:3// the response.total
342
+
}
343
+
}
344
+
}
345
+
```
346
+
347
+
It's possible that you'll want to store pagination information for more than one query. This might be for different components making queries against the same service, for example. You can use the `params.qid` (query identifier) property to assign a name to the query. If you set a `qid` of `mainListView`, for example, the pagination for this query will show up under `pagination.mainListView`. The `pagination.default` property will be used any time a `params.qid` is not provided. Here's an example of what this might look like:
ids: [0], // the ids in the store for the records that were returned from the server
357
+
limit:1, // the response.limit
358
+
skip:0, // the response.skip
359
+
total:3// the response.total
360
+
}
361
+
}
362
+
}
363
+
```
364
+
365
+
### The `find` getter
366
+
367
+
The `find` getter queries data from the local store using the same Feathers query syntax as on the server. It is synchronous and directly returns the results of the query. Pagination is **always** enabled and cannot be disabled. It accepts a params object with a `query` attribute. It does not use any other special attributes. The returned object looks just like a paginated result that you would receive from the server:
368
+
369
+
**`params = { query: {} }`**
370
+
```js
371
+
// The returned results object
372
+
{
373
+
data: [{ _id:1, ...etc }, ...etc],
374
+
limit:0,
375
+
skip:0,
376
+
total:3
377
+
}
378
+
```
379
+
380
+
381
+
###
382
+
321
383
## Customizing a Service's Default Store
322
384
323
385
As shown in the first example, the service module allows you to customize its store:
@@ -384,6 +446,6 @@ You can provide a `userService` in the auth plugin's options to automatically po
384
446
385
447
## License
386
448
387
-
Copyright (c) 2016
449
+
Copyright (c) Forever and Ever, or at least the current year.
0 commit comments