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: docs/guide/configurations.md
+24-2Lines changed: 24 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -137,11 +137,11 @@ In addition to [axios request options](https://github.com/axios/axios#request-co
137
137
138
138
### `persistBy`
139
139
140
+
> Since 0.9.3+
141
+
140
142
-**Type**: `string`
141
143
-**Default**: `'insertOrUpdate'`
142
144
143
-
> Since 0.9.3+
144
-
145
145
This option determines which Vuex ORM persist method should be called when Vuex ORM Axios attempts to save the response data to the store.
146
146
147
147
You can set this option to any one of the following string values:
@@ -151,6 +151,28 @@ In addition to [axios request options](https://github.com/axios/axios#request-co
151
151
-`update`
152
152
-`insertOrUpdate` (default)
153
153
154
+
### `persistOptions`
155
+
156
+
> Since 0.9.3+
157
+
158
+
-**Type**: `Object`
159
+
160
+
This option can be configured to control the persistence of relational data. Persist options are passed on to the persist method in the same manner Vuex ORM handles these options.
161
+
162
+
It's particularly useful when used together with the [`persistBy`](#persistby) option:
163
+
164
+
```js
165
+
User.api().get('/api/users', {
166
+
persistBy:'create',
167
+
persistOptions: {
168
+
insert: ['posts'],
169
+
insertOrUpdate: ['roles']
170
+
}
171
+
})
172
+
```
173
+
174
+
**See also**: [Vuex ORM - Insert Method for Relationships](https://vuex-orm.org/guide/data/inserting-and-updating.html#insert-method-for-relationships)
Copy file name to clipboardExpand all lines: docs/guide/usage.md
+13-4Lines changed: 13 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -94,19 +94,28 @@ Vuex ORM Axios will automatically save this data to the store, and the users ent
94
94
95
95
Under the hood, the plugin will persist data to the store by determining which records require inserting and which require updating. To accomplish this, the plugin passes data to the Vuex ORM `insertOrUpdate` model method. Therefore, only valid model attributes will be persisted to the store.
96
96
97
+
If you do not want to persist response data automatically, you can defer persistence by configuring the request with the `{ save: false }` option.
98
+
97
99
As of 0.9.3+ you may configure Vuex ORM Axios to persist data using an alternative Vuex ORM persist method other than the default `insertOrUpdate`. For example, you can refresh entities by passing the `persistBy` option as `'create'` which will persist data using the model's `create` method:
If you do not want to persist response data automatically, you can defer persistence by configuring the request with the `{ save: false }` option.
105
+
In addition, you can control how relations are persisted by passing the `persistOptions` option. Learn more about [Insert Method for Relationships](https://vuex-orm.org/guide/data/inserting-and-updating.html#insert-method-for-relationships) in the Vuex ORM documentation.
0 commit comments