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
This is equivalent to the model query syntax: `User.query().onlyTrashed().get()`
145
145
146
+
### Relationships
147
+
148
+
Soft deleted relations respect top level modifiers and retrieving them can be accomplished in the same fashion.
149
+
150
+
For example, if a soft deleted `User` model has soft deleted `Post` models, you would usually execute the following query chain:
151
+
152
+
```js
153
+
User.query().with('posts').withTrashed().get()
154
+
```
155
+
156
+
However, in cases where you may have soft deleted relations belonging to a non-deleted parent, you can use the usual relation closure:
157
+
158
+
```js
159
+
User.query().with('posts', (query) => {
160
+
query.onlyTrashed()
161
+
}).get()
162
+
```
163
+
164
+
Using modifiers in a query chain will impact both parent and nested relations. Using relation closures is the most efficient way of retrieving soft deleted relations in most cases, particularly when using the `onlyTrashed` modifier.
165
+
166
+
::: tip
167
+
When working with many-to-many relations, intermediate models intentionally ignore any soft delete filtering as these models are not often mutated and serve as a junction between models. This is also due to limitations in the Vuex ORM Query API.
168
+
:::
169
+
146
170
## Restoring
147
171
148
172
Sometimes you may wish to "un-delete" a soft deleted model. To restore a soft deleted model into an active state, use the `$restore` method on a model instance:
0 commit comments