MCPcopy
hub / github.com/prisma/prisma / toTS

Method toTS

packages/client-generator-js/src/TSClient/Model.ts:351–456  ·  packages/client-generator-js/src/TSClient/Model.ts::Model.toTS
()

Source from the content-addressed store, hash-verified

349 return ts.stringify(modelTypeExport)
350 }
351 public toTS(): string {
352 const { model } = this
353 const isComposite = this.dmmf.isComposite(model.name)
354
355 const omitType = ts.stringify(
356 buildOmitType({ modelName: this.model.name, context: this.context, fields: this.type.fields }),
357 {
358 newLine: class="st">'leading',
359 },
360 )
361
362 const hasRelationField = model.fields.some((f) => f.kind === class="st">'object')
363 const includeType = hasRelationField
364 ? ts.stringify(
365 buildIncludeType({ modelName: this.model.name, context: this.context, fields: this.type.fields }),
366 {
367 newLine: class="st">'leading',
368 },
369 )
370 : class="st">''
371
372 const createManyAndReturnIncludeType =
373 hasRelationField && this.createManyAndReturnType
374 ? ts.stringify(
375 buildIncludeType({
376 typeName: getIncludeCreateManyAndReturnName(this.model.name),
377 modelName: this.model.name,
378 context: this.context,
379 fields: this.createManyAndReturnType.fields,
380 }),
381 {
382 newLine: class="st">'leading',
383 },
384 )
385 : class="st">''
386
387 const updateManyAndReturnIncludeType =
388 hasRelationField && this.updateManyAndReturnType
389 ? ts.stringify(
390 buildIncludeType({
391 typeName: getIncludeUpdateManyAndReturnName(this.model.name),
392 modelName: this.model.name,
393 context: this.context,
394 fields: this.updateManyAndReturnType.fields,
395 }),
396 {
397 newLine: class="st">'leading',
398 },
399 )
400 : class="st">''
401
402 return `
403/**
404 * Model ${model.name}
405 */
406
407${!isComposite ? this.getAggregationTypes() : class="st">''}
408

Callers

nothing calls this directly

Calls 15

getAggregationTypesMethod · 0.95
getGroupByTypesMethod · 0.95
buildOmitTypeFunction · 0.90
buildIncludeTypeFunction · 0.90
buildSelectTypeFunction · 0.90
buildScalarSelectTypeFunction · 0.90
buildModelPayloadFunction · 0.90
getModelArgNameFunction · 0.90

Tested by

no test coverage detected