File tree Expand file tree Collapse file tree 4 files changed +45
-9
lines changed Expand file tree Collapse file tree 4 files changed +45
-9
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ be added to a static field in the model called `eagerLoad` to have them eagerly
7
7
8
8
Example:
9
9
10
- ``` javascript
10
+ ``` javascript{3}
11
11
class User extends Model {
12
12
static entity = 'users';
13
13
static eagerLoad = ['posts'];
Original file line number Diff line number Diff line change @@ -52,20 +52,50 @@ const comments = Comment.getters('all');
52
52
When fetching all returned records replace the respective existing records in the Vuex-ORM database.
53
53
54
54
55
- ## Fetching single record
55
+ ## Fetching a single record
56
56
57
- ::: danger
58
- TODO
59
- :::
57
+ You can also fetch single records via ID:
60
58
59
+ ``` javascript
60
+ Comment .dispatch (' fetch' , { filter: { id: 42 }});
61
+ ```
62
+
63
+ It automatically recognizes, that you're requesting a single record and sends a GraphQL Query for a single record:
64
+
65
+ ``` graphql
66
+ query Comment ($id : ID ! ) {
67
+ comment (id : $id ) {
68
+ id
69
+ content
70
+ postId
71
+ userId
72
+
73
+ user {
74
+ id
75
+ email
76
+ }
77
+
78
+ post {
79
+ id
80
+ content
81
+ title
82
+
83
+ user {
84
+ id
85
+ email
86
+ }
87
+ }
88
+ }
89
+ }
90
+ ```
61
91
62
92
63
93
## Filtering
64
94
65
95
Additionally you can pass a filter object to the fetch action like this:
66
96
67
97
``` javascript
68
- Comment .dispatch (' fetch' , { postId: 15 , deleted: false });
98
+ Comment .dispatch (' fetch' , { filter : { postId: 15 , deleted: false } });
69
99
```
70
100
71
101
This will generate the following GraphQL query:
Original file line number Diff line number Diff line change 197
197
198
198
199
199
::: danger
200
- * TODO:*
200
+ ** TODO:* *
201
201
202
202
- Example Queries
203
203
:::
Original file line number Diff line number Diff line change @@ -28,7 +28,13 @@ These are the possible options to pass when calling `VuexORM.use()`:
28
28
29
29
- ` database ` (required): The Vuex-ORM database.
30
30
- ` url ` (optional, default: '/graphql'): The URL to the graphql api. Will be passed to apollo-client.
31
- - ` debug ` (optional, default: false): Set to true to activate the debug logging. We recommend to activate this in
32
- development env.
31
+ - ` debug ` (optional, default: false): Set to true to activate the debug logging.
33
32
34
33
More options will come in future releases.
34
+
35
+ ::: tip
36
+ We recommend to activate the debug mode in development env automatically via:
37
+ ``` javascript
38
+ { debug: process .env .NODE_ENV !== ' production' }
39
+ ```
40
+ :::
You can’t perform that action at this time.
0 commit comments