MCPcopy
hub / github.com/prisma/prisma / fetch

Function fetch

sandbox/d1/src/index.ts:25–142  ·  view source on GitHub ↗
(request: Request, env: Env, ctx: ExecutionContext)

Source from the content-addressed store, hash-verified

23
24export default {
25 async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
26 const adapter = new PrismaD1(env.MY_DATABASE);
27 const prisma = new PrismaClient({ adapter });
28
29 let tenc = new TextEncoder();
30 let buffer = tenc.encode('Hello');
31
32 // let buffer = Uint8Array.from(['H', 'e', 'l', 'l', 'o'])
33
34 const qr = await prisma.$queryRaw`
35 INSERT INTO "Test"
36 ("boolean", "blob")
37 VALUES (true, ${buffer})
38 RETURNING *
39 `;
40 console.log({ qr });
41
42 console.log('--------');
43
44 // const result = await prisma.test.findUnique({
45 // where: {
46 // id: qr.re
47 // }
48 // })
49
50 // const result = await prisma.customers.create({
51 // data: {
52 // companyName: "Test Company",
53 // contactName: "Test Contact",
54 // }
55 // })
56
57 // const result = await prisma.customers.create({
58 // data: {
59 // companyName: "Test Company",
60 // contactName: "Test Contact",
61 // },
62 // select: {
63 // customerId: true,
64 // }
65 // })
66
67 // const result = await prisma.customers.findMany({
68 // where: {
69 // customerId: {
70 // equals: 1
71 // }
72 // }
73 // })
74
75 // const result = await prisma.prismaTest.findFirst()
76
77 // const result = await prisma.test.findFirst()
78
79 // const result = await prisma.$executeRaw`
80 // DELETE FROM Customers
81 // `
82

Callers 2

areEcosystemTestsPassingFunction · 0.50
getCommitInfoFunction · 0.50

Calls 2

$queryRawMethod · 0.95
logMethod · 0.80

Tested by

no test coverage detected