Skip to content

Commit

Permalink
Merge pull request #6 from fauh45/master
Browse files Browse the repository at this point in the history
  • Loading branch information
adeyahya authored Apr 28, 2022
2 parents e80aa8c + c663753 commit f7aaa0d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ model User {
posts Post[]
keywords String[]
biography Json
decimal Decimal
biginteger BigInt
}

model Post {
Expand Down
2 changes: 2 additions & 0 deletions prisma/typebox/Post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export const Post = Type.Object({
role: Type.Optional(Role),
keywords: Type.Array(Type.String()),
biography: Type.String(),
decimal: Type.Number(),
biginteger: Type.Integer(),
})
),
userId: Type.Optional(Type.Number()),
Expand Down
2 changes: 2 additions & 0 deletions prisma/typebox/PostInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export const PostInput = Type.Object({
role: Type.Optional(Role),
keywords: Type.Array(Type.String()),
biography: Type.String(),
decimal: Type.Number(),
biginteger: Type.Integer(),
})
),
userId: Type.Optional(Type.Number()),
Expand Down
2 changes: 2 additions & 0 deletions prisma/typebox/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export const User = Type.Object({
),
keywords: Type.Array(Type.String()),
biography: Type.String(),
decimal: Type.Number(),
biginteger: Type.Integer(),
});

export type UserType = Static<typeof User>;
2 changes: 2 additions & 0 deletions prisma/typebox/UserInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export const UserInput = Type.Object({
),
keywords: Type.Array(Type.String()),
biography: Type.String(),
decimal: Type.Number(),
biginteger: Type.Integer(),
});

export type UserInputType = Static<typeof UserInput>;
4 changes: 3 additions & 1 deletion src/generator/transformDMMF.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ const transformField = (field: DMMF.Field) => {
let inputTokens = [];
const deps = new Set();

if (['Int', 'Float'].includes(field.type)) {
if (['Int', 'Float', 'Decimal'].includes(field.type)) {
tokens.push('Type.Number()');
} else if (['BigInt'].includes(field.type)) {
tokens.push('Type.Integer()');
} else if (['String', 'DateTime', 'Json', 'Date'].includes(field.type)) {
tokens.push('Type.String()');
} else if (field.type === 'Boolean') {
Expand Down

0 comments on commit f7aaa0d

Please sign in to comment.