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
77
88Example:
99
10- ``` javascript
10+ ``` javascript{3}
1111class User extends Model {
1212 static entity = 'users';
1313 static eagerLoad = ['posts'];
Original file line number Diff line number Diff line change @@ -52,20 +52,50 @@ const comments = Comment.getters('all');
5252When fetching all returned records replace the respective existing records in the Vuex-ORM database.
5353
5454
55- ## Fetching single record
55+ ## Fetching a single record
5656
57- ::: danger
58- TODO
59- :::
57+ You can also fetch single records via ID:
6058
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+ ```
6191
6292
6393## Filtering
6494
6595Additionally you can pass a filter object to the fetch action like this:
6696
6797``` javascript
68- Comment .dispatch (' fetch' , { postId: 15 , deleted: false });
98+ Comment .dispatch (' fetch' , { filter : { postId: 15 , deleted: false } });
6999```
70100
71101This will generate the following GraphQL query:
Original file line number Diff line number Diff line change 197197
198198
199199::: danger
200- * TODO:*
200+ ** TODO:* *
201201
202202- Example Queries
203203:::
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()`:
2828
2929- ` database ` (required): The Vuex-ORM database.
3030- ` 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.
3332
3433More 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