Skip to content

Commit 3d1305d

Browse files
authored
templates: fixes the seeding for the website template when using postgres (#9758)
1 parent 0829a35 commit 3d1305d

File tree

1 file changed

+10
-32
lines changed
  • templates/website/src/endpoints/seed

1 file changed

+10
-32
lines changed

templates/website/src/endpoints/seed/index.ts

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ export const seed = async ({
3737
// as well as the collections and globals
3838
// this is because while `yarn seed` drops the database
3939
// the custom `/api/seed` endpoint does not
40-
41-
payload.logger.info(`— Clearing media...`)
4240
payload.logger.info(`— Clearing collections and globals...`)
43-
4441
// clear the database
4542
await Promise.all(
4643
globals.map((global) =>
@@ -57,31 +54,16 @@ export const seed = async ({
5754
),
5855
)
5956

60-
await Promise.all(
61-
collections.map((collection) =>
62-
payload.delete({
63-
collection: collection,
64-
where: {
65-
id: {
66-
exists: true,
67-
},
68-
},
69-
depth: 0,
70-
context: {
71-
disableRevalidate: true,
72-
},
73-
}),
74-
),
75-
)
76-
77-
const pages = await payload.delete({
78-
collection: 'pages',
79-
where: {},
80-
context: {
81-
disableRevalidate: true,
82-
},
83-
depth: 0,
84-
})
57+
for (const collection of collections) {
58+
await payload.delete({
59+
collection: collection,
60+
where: {},
61+
depth: 0,
62+
context: {
63+
disableRevalidate: true,
64+
},
65+
})
66+
}
8567

8668
payload.logger.info(`— Seeding demo author and user...`)
8769

@@ -217,7 +199,6 @@ export const seed = async ({
217199
context: {
218200
disableRevalidate: true,
219201
},
220-
select: { content: false },
221202
data: JSON.parse(
222203
JSON.stringify({ ...post1, categories: [technologyCategory.id] })
223204
.replace(/"\{\{IMAGE_1\}\}"/g, String(image1ID))
@@ -232,7 +213,6 @@ export const seed = async ({
232213
context: {
233214
disableRevalidate: true,
234215
},
235-
select: { content: false },
236216
data: JSON.parse(
237217
JSON.stringify({ ...post2, categories: [newsCategory.id] })
238218
.replace(/"\{\{IMAGE_1\}\}"/g, String(image2ID))
@@ -247,7 +227,6 @@ export const seed = async ({
247227
context: {
248228
disableRevalidate: true,
249229
},
250-
select: { content: false },
251230
data: JSON.parse(
252231
JSON.stringify({ ...post3, categories: [financeCategory.id] })
253232
.replace(/"\{\{IMAGE_1\}\}"/g, String(image3ID))
@@ -284,7 +263,6 @@ export const seed = async ({
284263
const contactForm = await payload.create({
285264
collection: 'forms',
286265
depth: 0,
287-
select: { title: true },
288266
data: JSON.parse(JSON.stringify(contactFormData)),
289267
})
290268

0 commit comments

Comments
 (0)