-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathindex.ts
More file actions
30 lines (24 loc) · 817 Bytes
/
index.ts
File metadata and controls
30 lines (24 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { PrismaClient } from '../prisma/generated/client';
import { withAccelerate } from '@prisma/extension-accelerate'
const prisma = new PrismaClient({
accelerateUrl: process.env.DATABASE_URL,
}).$extends(withAccelerate());
async function main() {
const newUser = await prisma.user.create({
data: {
name: 'Percy Prisma',
email: 'percy@prisma.io',
},
});
console.log('The new user:', newUser);
const users = await prisma.user.findMany({
cacheStrategy: { ttl: 60 },
});
console.log('All users:', users);
const cachedUsers = await prisma.user.findMany({
cacheStrategy: { ttl: 60 },
}).withAccelerateInfo();
console.log('Cached users:', cachedUsers);
// See more examples of how to use Prisma Accelerate: https://www.prisma.io/docs/accelerate/examples
}
main();