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
### What?
The REST SDK documents a `trash` option on `find`, `findVersions`, and
`findVersionByID`, but that flag was never added to the request URL. The
Local API and REST handlers already support `trash` via query params
(`parseParams` / collection endpoints).
### Why?
Users enabling [soft delete
(trash)](https://payloadcms.com/docs/trash/overview) need `trash: true`
on list/version queries to include trashed documents (or to query the
trash view). Passing `trash` from the SDK had no effect because
`buildSearchParams` omitted it, so the REST API always behaved as if
`trash` was unset.
### How?
- Extended `OperationArgs` in
`packages/sdk/src/utilities/buildSearchParams.ts` with optional `trash?:
boolean`.
- When `trash` is a boolean, serialize it to the query string (same
pattern as `draft`).
- Added an integration test in `test/sdk/int.spec.ts` that uses a stub
`fetch` and asserts the requested URL contains `trash=true` for `find`,
`findVersions`, and `findVersionByID`.
**Before:** `sdk.find({ collection: 'posts', trash: true })` → request
had no `trash` query param.
**After:** same call → `...?trash=true&...` (alongside other params).
Fixes #
---
- To see the specific tasks where the Asana app for GitHub is being
used, see below:
- https://app.asana.com/0/0/1213864434332542
---------
Co-authored-by: Sasha Rakhmatulin <sasha@ritsuko.dev>
Copy file name to clipboardExpand all lines: packages/sdk/src/collections/delete.ts
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,11 @@ export type DeleteBaseOptions<
38
38
* Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.
39
39
*/
40
40
select?: TSelect
41
+
/**
42
+
* When the collection has `trash` enabled: use with the REST API semantics for permanent delete vs bulk operations on trashed docs.
Copy file name to clipboardExpand all lines: packages/sdk/src/collections/findByID.ts
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -59,6 +59,11 @@ export type FindByIDOptions<
59
59
* Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.
60
60
*/
61
61
populate?: PopulateType<T>
62
+
/**
63
+
* When `true`, returns the document even if it is trashed. No effect unless the collection has `trash` enabled.
Copy file name to clipboardExpand all lines: packages/sdk/src/collections/update.ts
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -67,6 +67,11 @@ export type UpdateBaseOptions<
67
67
* Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.
68
68
*/
69
69
select?: TSelect
70
+
/**
71
+
* When `true`, the operation can target trashed (soft-deleted) documents. No effect unless the collection has `trash` enabled.
0 commit comments