-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-db.js
More file actions
32 lines (28 loc) · 760 Bytes
/
test-db.js
File metadata and controls
32 lines (28 loc) · 760 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
31
32
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function main() {
try {
const userCount = await prisma.user.count();
console.log(`Database connection successful! Found ${userCount} users.`);
// Get a sample user to verify data access
const users = await prisma.user.findMany({
take: 1,
select: {
id: true,
email: true,
name: true,
isAdmin: true
}
});
if (users.length > 0) {
console.log('Sample user:', users[0]);
} else {
console.log('No users found in the database.');
}
} catch (error) {
console.error('Error connecting to database:', error);
} finally {
await prisma.$disconnect();
}
}
main();