MCPcopy
hub / github.com/prisma/prisma / ModelFieldRefs

Class ModelFieldRefs

packages/client-generator-js/src/TSClient/ModelFieldRefs.ts:6–32  ·  packages/client-generator-js/src/TSClient/ModelFieldRefs.ts::ModelFieldRefs

Source from the content-addressed store, hash-verified

4import { Generable } from class="st">'./Generable'
5
6export class ModelFieldRefs implements Generable {
7 constructor(protected outputType: DMMF.OutputType) {}
8 toTS() {
9 const { name } = this.outputType
10 return `
11
12/**
13 * Fields of the ${name} model
14 */
15interface ${getFieldRefsTypeName(name)} {
16${this.stringifyFields()}
17}
18 `
19 }
20
21 private stringifyFields() {
22 const { name } = this.outputType
23 return this.outputType.fields
24 .filter((field) => field.outputType.location !== class="st">'outputObjectTypes')
25 .map((field) => {
26 const fieldOutput = field.outputType
27 const refTypeName = getRefAllowedTypeName(fieldOutput)
28 return ` readonly ${field.name}: FieldRef<class="st">"${name}", ${refTypeName}>`
29 })
30 .join(class="st">'\n')
31 }
32}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected