This file contains 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 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 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 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 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 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 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 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 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
class PrismaUser<T> implements PrismaPromise<T> { | |
[prisma]: true; | |
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2> { | |
throw new Error("Method not implemented."); | |
} | |
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult> { | |
throw new Error("Method not implemented."); | |
} | |
[Symbol.toStringTag]: string; |
This file contains 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 Tuple<A, N extends number, T extends unknown[] = []> = { | |
0: Tuple<A, N, [...T, A]> | |
1: T | |
}[ | |
T['length'] extends N | |
? 1 | |
: 0 | |
]; | |
type test0 = Tuple<'coucou', 4>; |
NewerOlder