-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathscenario.mjs
More file actions
46 lines (38 loc) · 1.04 KB
/
scenario.mjs
File metadata and controls
46 lines (38 loc) · 1.04 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { PrismaPg } from '@prisma/adapter-pg';
import { PrismaClient } from '@prisma/client';
import * as Sentry from '@sentry/node';
import { randomBytes } from 'crypto';
// Stop the process from exiting before the transaction is sent
setInterval(() => {}, 1000);
const connectionString = 'postgresql://prisma:prisma@localhost:5435/tests';
async function run() {
await Sentry.startSpan(
{
name: 'Test Transaction',
op: 'transaction',
},
async span => {
const adapter = new PrismaPg({ connectionString });
const client = new PrismaClient({ adapter });
await client.user.create({
data: {
name: 'Tilda',
email: `tilda_${randomBytes(4).toString('hex')}@sentry.io`,
},
});
await client.user.findMany();
await client.user.deleteMany({
where: {
email: {
contains: 'sentry.io',
},
},
});
setTimeout(async () => {
span.end();
await client.$disconnect();
}, 500);
},
);
}
run();