MCPcopy
hub / github.com/prisma/prisma / main

Function main

packages/client/src/__tests__/benchmarks/lots-of-relations/builder.ts:8–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6// can be used to generate schema for this benchmark
7// generated schema needs `format` pass to be valid
8async function main() {
9 const models = Array.from({ length: MODELS_COUNT }).map((v, i) => `Model${i}`)
10 const modelsStr = models
11 .map((modelName, currentModelIdx) => {
12 const fields = ['id Int @id']
13 for (let i = 0; i < fieldsCount; i++) {
14 const modelIdx = (currentModelIdx + i + 1) % MODELS_COUNT
15 fields.push(`model${modelIdx}Id Int`)
16 fields.push(`model${modelIdx} Model${modelIdx} @relation(fields: [model${modelIdx}Id], references: [id])`)
17 }
18
19 return `
20 model ${modelName} {
21 ${fields.join('\n')}
22 }
23 `
24 })
25 .join('\n')
26
27 const str = `
28 generator client {
29 provider = "prisma-client-js"
30 }
31
32 datasource db {
33 provider = "postgresql"
34 }
35
36 ${modelsStr}
37 `
38
39 await fs.writeFile('schema.prisma', str)
40}
41
42void main()

Callers 1

builder.tsFile · 0.70

Calls 2

fromMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected