UNPKG

@tsed/prisma

Version:

Generate Ts.ED JsonSchema based on Prisma models

36 lines (35 loc) 928 B
import { parseDocumentationAttributes } from "../utils/parseDocumentationAttributes.js"; export class DmmfField { constructor({ field, schemaArg, model }) { this.field = field; this.model = model; this.schemaArg = schemaArg; } get name() { return this.field.name; } get isRequired() { return this.field.isRequired; } get type() { return this.field.type; } get isList() { return this.field.isList; } get kind() { return this.field.kind; } get isNullable() { return this.schemaArg.isNullable; } get location() { return this.field.kind === "enum" ? "enumTypes" : this.field.kind === "object" ? "inputObjectTypes" : "scalar"; } getAdditionalDecorators() { return parseDocumentationAttributes(this.field.documentation); } toString() { return this.name; } }