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

Function main

packages/client/src/__tests__/benchmarks/huge-schema/builder.ts:29–77  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27}
28
29function main() {
30 let schema = `
31generator client {
32 provider = "prisma-client-js"
33 previewFeatures = ["groupBy"]
34}
35
36datasource db {
37 provider = "postgresql"
38 }
39
40 `
41 const ts = `
42import { PrismaClient } from '@prisma/client'
43const client = new PrismaClient();
44
45async function main(){
46 const a = await client.model1.findMany()
47}
48main().catch(err => console.log(err))
49`
50 const modelMap = new Map<string, Model>()
51 for (let i = 1; i < 50; i++) {
52 const modelName = `Model${i}`
53 const model = new Model({
54 name: modelName,
55 body: ` id Int @id @default(autoincrement())
56 int Int
57 optionalInt Int?
58 float Float
59 optionalFloat Float?
60 string String
61 optionalString String?
62 json Json
63 optionalJson Json?
64 boolean Boolean
65 optionalBoolean Boolean?`,
66 })
67 modelMap.set(modelName, model)
68 }
69 modelMap.forEach((model) => {
70 schema += model.build()
71 })
72 const schemaPath = path.join(__dirname, 'schema.prisma')
73 const tsPath = path.join(__dirname, 'compile.ts')
74
75 write(schemaPath, schema)
76 write(tsPath, ts)
77}
78
79main()

Callers 1

builder.tsFile · 0.70

Calls 3

buildMethod · 0.95
setMethod · 0.80
writeFunction · 0.70

Tested by

no test coverage detected