By default, gtype follow the same basic rule as prisma generate, eg: mark optional for all property when making xxUpdateInput. You can change most of the them in tealina.config.mjs
js
// @ts-check
import { defineConfig } from 'tealina'
export default defineConfig({
gtype:{
// ...
}
})// @ts-check
import { defineConfig } from 'tealina'
export default defineConfig({
gtype:{
// ...
}
})Partial Overwrite
Exlude the id property
js
{
overwrite: {
excludeProps: [
{
blockName: '*',// '*' for all model and type you declare
keyword: 'model',
kind: 'CreateInput',
predicate: p => p.name === 'id',
},
],
},
}{
overwrite: {
excludeProps: [
{
blockName: '*',// '*' for all model and type you declare
keyword: 'model',
kind: 'CreateInput',
predicate: p => p.name === 'id',
},
],
},
}prisma
model Category {
id Int @id @default(autoincrement())
categoryName String
description String
products Product[]
}
model Category {
id Int @id @default(autoincrement())
categoryName String
description String
products Product[]
}ts
interface Category {
categoryName: string
description: string
}
interface Category {
categoryName: string
description: string
}Type remap
Type remap is more straightforward than overwrite, and effect all kind,(model,type,xxCreateInput,xxUpdateInput,xx)
js
{
typeRemap: type => {
switch (type) {
case 'Date':
return 'number | string'
// ....
default:
// retrun null fallback to default stategy
return null
}
},
}{
typeRemap: type => {
switch (type) {
case 'Date':
return 'number | string'
// ....
default:
// retrun null fallback to default stategy
return null
}
},
}The default type Map
ts
/** https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#model-field-scalar-types */
const justMap = new Map<string, string>([
['BigInt', 'bigint'],
['Int', 'number'],
['Float', 'number'],
['Decimal', 'number'],
['String', 'string'],
['DateTime', 'Date'],
['Boolean', 'boolean'],
['Json', 'JsonValue'],
['Bytes', 'Buffer'],
])/** https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#model-field-scalar-types */
const justMap = new Map<string, string>([
['BigInt', 'bigint'],
['Int', 'number'],
['Float', 'number'],
['Decimal', 'number'],
['String', 'string'],
['DateTime', 'Date'],
['Boolean', 'boolean'],
['Json', 'JsonValue'],
['Bytes', 'Buffer'],
])