This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| mkdir -p out | |
| npx tsc src/index.ts -d --emitDeclarationOnly --module amd --outFile out/index.d.ts && | |
| echo " | |
| declare module '<npm package name>' { | |
| import main = require('index'); | |
| export = main; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { PrismaClient, Prisma } from "@prisma/client" | |
| type Operation = | |
| | 'findFirst' | |
| | 'findFirstOrThrow' | |
| | 'findUnique' | |
| | 'findUniqueOrThrow' | |
| | 'findMany' | |
| | 'create' | |
| | 'createMany' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { | |
| A, | |
| F, | |
| B, | |
| O, | |
| I, | |
| } from 'ts-toolbelt'; | |
| type OnlyUserKeys<O> = | |
| O extends L.List |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { PrismaClient } from ".prisma/client"; | |
| /* | |
| model CommentOptionalProp { | |
| id String @id @default(auto()) @map("_id") @db.ObjectId | |
| country String? | |
| content CommentContent? | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { PrismaClient } from ".prisma/client"; | |
| /** | |
| model Comment { | |
| id String @id @default(auto()) @map("_id") @db.ObjectId | |
| country String? | |
| content CommentContent? | |
| contents CommentContent[] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { PrismaClient } from ".prisma/client"; | |
| (async () => { | |
| const prisma = new PrismaClient(); | |
| await prisma.user.create({ | |
| data: { | |
| email: Date.now() + "", | |
| }, | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type MarkUndefinable<A, B> = { | |
| [K in keyof A]: A[K] extends O.Object | |
| ? MarkUndefinable<A[K], A.At<B, K>> | |
| : K extends keyof B ? A[K] | undefined : A[K] | |
| } | |
| type UnionizeDeep<A extends object, B extends object> = | |
| O.Merge<MarkUndefinable<A, B>, B, 'deep', M.BuiltIn, undefined> | |
| type test = A.Compute<UnionizeDeep<{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const checkNumber = check((thing: unknown) => { | |
| if (typeof thing === 'number') { | |
| return thing; | |
| } | |
| return ko(new E.NOT_NUMBER(thing)); | |
| }); | |
| const main = check(() => { | |
| const [number0, e0] = checkNumber(9); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { PrismaClient, Prisma } from '@prisma/client' | |
| async function main() { | |
| const prisma = new PrismaClient() | |
| // Define a type that includes the relation to `Post` | |
| const userWithPosts = Prisma.validator<Prisma.UserArgs>()({ | |
| include: { posts: true } | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { PrismaClient, Prisma } from '@prisma/client' | |
| async function main() { | |
| const prisma = new PrismaClient() | |
| // Define a type that includes the relation to `Post` | |
| const userWithPosts = Prisma.validator<Prisma.UserArgs>()({ | |
| include: { posts: true } | |
| }) |
NewerOlder