Skip to content

Commit a06d83e

Browse files
committed
seed
1 parent 3bce086 commit a06d83e

File tree

1 file changed

+222
-0
lines changed

1 file changed

+222
-0
lines changed

test/tree-view/collections/Tags/index.ts

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,228 @@ export const TagsCollection: CollectionConfig = {
88
admin: {
99
useAsTitle: 'name',
1010
},
11+
endpoints: [
12+
{
13+
path: '/seed-data',
14+
method: 'post',
15+
handler: async (req) => {
16+
const { payload } = req
17+
18+
// Clear existing tags
19+
await payload.delete({
20+
collection: 'tags',
21+
where: {},
22+
})
23+
24+
// Root level folders
25+
const categories = await payload.create({
26+
collection: 'tags',
27+
data: { name: 'Categories' },
28+
})
29+
30+
const projects = await payload.create({
31+
collection: 'tags',
32+
data: { name: 'Projects' },
33+
})
34+
35+
const archived = await payload.create({
36+
collection: 'tags',
37+
data: { name: 'Archived' },
38+
})
39+
40+
// Categories children
41+
const frontend = await payload.create({
42+
collection: 'tags',
43+
data: { name: 'Frontend', _parentDoc: categories.id },
44+
})
45+
46+
const backend = await payload.create({
47+
collection: 'tags',
48+
data: { name: 'Backend', _parentDoc: categories.id },
49+
})
50+
51+
const design = await payload.create({
52+
collection: 'tags',
53+
data: { name: 'Design', _parentDoc: categories.id },
54+
})
55+
56+
// Frontend children
57+
const react = await payload.create({
58+
collection: 'tags',
59+
data: { name: 'React', _parentDoc: frontend.id },
60+
})
61+
62+
const vue = await payload.create({
63+
collection: 'tags',
64+
data: { name: 'Vue', _parentDoc: frontend.id },
65+
})
66+
67+
const css = await payload.create({
68+
collection: 'tags',
69+
data: { name: 'CSS', _parentDoc: frontend.id },
70+
})
71+
72+
// React children (leaf nodes)
73+
await payload.create({
74+
collection: 'tags',
75+
data: { name: 'Hooks', _parentDoc: react.id },
76+
})
77+
78+
await payload.create({
79+
collection: 'tags',
80+
data: { name: 'Components', _parentDoc: react.id },
81+
})
82+
83+
await payload.create({
84+
collection: 'tags',
85+
data: { name: 'State Management', _parentDoc: react.id },
86+
})
87+
88+
// Vue children (leaf nodes)
89+
await payload.create({
90+
collection: 'tags',
91+
data: { name: 'Composition API', _parentDoc: vue.id },
92+
})
93+
94+
await payload.create({
95+
collection: 'tags',
96+
data: { name: 'Pinia', _parentDoc: vue.id },
97+
})
98+
99+
// CSS children (leaf nodes)
100+
await payload.create({
101+
collection: 'tags',
102+
data: { name: 'Tailwind', _parentDoc: css.id },
103+
})
104+
105+
await payload.create({
106+
collection: 'tags',
107+
data: { name: 'SCSS', _parentDoc: css.id },
108+
})
109+
110+
// Backend children
111+
const nodejs = await payload.create({
112+
collection: 'tags',
113+
data: { name: 'Node.js', _parentDoc: backend.id },
114+
})
115+
116+
const databases = await payload.create({
117+
collection: 'tags',
118+
data: { name: 'Databases', _parentDoc: backend.id },
119+
})
120+
121+
const apis = await payload.create({
122+
collection: 'tags',
123+
data: { name: 'APIs', _parentDoc: backend.id },
124+
})
125+
126+
// Node.js children (leaf nodes)
127+
await payload.create({
128+
collection: 'tags',
129+
data: { name: 'Express', _parentDoc: nodejs.id },
130+
})
131+
132+
await payload.create({
133+
collection: 'tags',
134+
data: { name: 'Fastify', _parentDoc: nodejs.id },
135+
})
136+
137+
// Databases children (leaf nodes)
138+
await payload.create({
139+
collection: 'tags',
140+
data: { name: 'MongoDB', _parentDoc: databases.id },
141+
})
142+
143+
await payload.create({
144+
collection: 'tags',
145+
data: { name: 'PostgreSQL', _parentDoc: databases.id },
146+
})
147+
148+
await payload.create({
149+
collection: 'tags',
150+
data: { name: 'Redis', _parentDoc: databases.id },
151+
})
152+
153+
// APIs children (leaf nodes)
154+
await payload.create({
155+
collection: 'tags',
156+
data: { name: 'REST', _parentDoc: apis.id },
157+
})
158+
159+
await payload.create({
160+
collection: 'tags',
161+
data: { name: 'GraphQL', _parentDoc: apis.id },
162+
})
163+
164+
// Design children (leaf nodes)
165+
await payload.create({
166+
collection: 'tags',
167+
data: { name: 'UI/UX', _parentDoc: design.id },
168+
})
169+
170+
await payload.create({
171+
collection: 'tags',
172+
data: { name: 'Figma', _parentDoc: design.id },
173+
})
174+
175+
await payload.create({
176+
collection: 'tags',
177+
data: { name: 'Design Systems', _parentDoc: design.id },
178+
})
179+
180+
// Projects children
181+
const activeProjects = await payload.create({
182+
collection: 'tags',
183+
data: { name: 'Active', _parentDoc: projects.id },
184+
})
185+
186+
const planning = await payload.create({
187+
collection: 'tags',
188+
data: { name: 'Planning', _parentDoc: projects.id },
189+
})
190+
191+
// Active projects (leaf nodes)
192+
await payload.create({
193+
collection: 'tags',
194+
data: { name: 'E-commerce Platform', _parentDoc: activeProjects.id },
195+
})
196+
197+
await payload.create({
198+
collection: 'tags',
199+
data: { name: 'Mobile App', _parentDoc: activeProjects.id },
200+
})
201+
202+
await payload.create({
203+
collection: 'tags',
204+
data: { name: 'Dashboard Redesign', _parentDoc: activeProjects.id },
205+
})
206+
207+
// Planning projects (leaf nodes)
208+
await payload.create({
209+
collection: 'tags',
210+
data: { name: 'AI Integration', _parentDoc: planning.id },
211+
})
212+
213+
await payload.create({
214+
collection: 'tags',
215+
data: { name: 'Performance Optimization', _parentDoc: planning.id },
216+
})
217+
218+
// Archived (leaf nodes at root level)
219+
await payload.create({
220+
collection: 'tags',
221+
data: { name: '2023 Projects', _parentDoc: archived.id },
222+
})
223+
224+
await payload.create({
225+
collection: 'tags',
226+
data: { name: 'Legacy Code', _parentDoc: archived.id },
227+
})
228+
229+
return Response.json({ success: true, message: 'Seed data created with 50+ tags' })
230+
},
231+
},
232+
],
11233
fields: [
12234
{
13235
name: 'name',

0 commit comments

Comments
 (0)