-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-users.js
More file actions
30 lines (23 loc) · 792 Bytes
/
check-users.js
File metadata and controls
30 lines (23 loc) · 792 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
const { PrismaClient } = require('@prisma/client')
const prisma = new PrismaClient()
async function checkUsers() {
console.log('\n👥 Checking all users in database:\n')
const users = await prisma.user.findMany({
orderBy: { createdAt: 'desc' }
})
console.log(`Found ${users.length} users:\n`)
for (const user of users) {
console.log(`📋 User: ${user.id}`)
console.log(` Name: ${user.name || 'N/A'}`)
console.log(` Email: ${user.email || 'N/A'}`)
console.log(` Created: ${user.createdAt}`)
// 查询消息数量
const messageCount = await prisma.message.count({
where: { userId: user.id }
})
console.log(` Messages: ${messageCount}`)
console.log('')
}
await prisma.$disconnect()
}
checkUsers().catch(console.error)