Compare commits

...

1 Commits

Author SHA1 Message Date
Jarrod Flesch
7d36e23311 fix(plugin-nested-docs): update with db adapter on create 2025-09-02 11:38:07 -04:00
3 changed files with 11 additions and 5 deletions

7
.vscode/launch.json vendored
View File

@@ -160,6 +160,13 @@
"request": "launch",
"type": "node-terminal"
},
{
"command": "pnpm tsx --no-deprecation test/dev.ts plugin-search",
"cwd": "${workspaceFolder}",
"name": "Run Dev plugin-search",
"request": "launch",
"type": "node-terminal"
},
{
"command": "pnpm run test:int live-preview",
"cwd": "${workspaceFolder}",

View File

@@ -17,7 +17,7 @@ export const resaveSelfAfterCreate =
const breadcrumbs = doc[breadcrumbSlug] as unknown as Breadcrumb[]
try {
await payload.update({
await payload.db.updateOne({
id: doc.id,
collection: collection.slug,
data: {
@@ -27,9 +27,8 @@ export const resaveSelfAfterCreate =
doc: breadcrumbs.length === i + 1 ? doc.id : crumb.doc,
})) || [],
},
depth: 0,
draft: collection.versions.drafts && doc._status !== 'published',
locale,
locale: locale || undefined,
req,
})
} catch (err: unknown) {

View File

@@ -53,13 +53,13 @@ export const nestedDocsPlugin =
hooks: {
...(collection.hooks || {}),
afterChange: [
...(collection?.hooks?.afterChange || []),
resaveChildren(pluginConfig),
resaveSelfAfterCreate(pluginConfig),
...(collection?.hooks?.afterChange || []),
],
beforeChange: [
populateBreadcrumbsBeforeChange(pluginConfig),
...(collection?.hooks?.beforeChange || []),
populateBreadcrumbsBeforeChange(pluginConfig),
],
},
}