-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-db.js
More file actions
50 lines (41 loc) · 1.19 KB
/
check-db.js
File metadata and controls
50 lines (41 loc) · 1.19 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
47
48
49
50
// Database check script
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function main() {
try {
// Check equipment count
const equipmentCount = await prisma.equipment.count();
console.log('Total equipment items:', equipmentCount);
if (equipmentCount > 0) {
const equipment = await prisma.equipment.findMany({
take: 3,
orderBy: { createdAt: 'desc' }
});
console.log('Recent equipment:', JSON.stringify(equipment.map(eq => ({
id: eq.id,
title: eq.title,
dailyRate: eq.dailyRate
})), null, 2));
}
// Check user count
const userCount = await prisma.user.count();
console.log('Total users:', userCount);
if (userCount > 0) {
const users = await prisma.user.findMany({
take: 3,
select: {
id: true,
name: true,
email: true
},
orderBy: { createdAt: 'desc' }
});
console.log('Recent users:', JSON.stringify(users, null, 2));
}
} catch (error) {
console.error('Error querying database:', error);
} finally {
await prisma.$disconnect();
}
}
main();