58 lines
1.3 KiB
JavaScript
58 lines
1.3 KiB
JavaScript
const { PrismaClient } = require('@prisma/client');
|
|
|
|
const prisma = new PrismaClient({
|
|
datasources: {
|
|
db: {
|
|
url: process.env.DATABASE_URL
|
|
}
|
|
}
|
|
});
|
|
|
|
async function main() {
|
|
try {
|
|
console.log('正在查询管理员账号...\n');
|
|
|
|
const admins = await prisma.user.findMany({
|
|
where: {
|
|
role: 'admin'
|
|
},
|
|
select: {
|
|
id: true,
|
|
username: true,
|
|
name: true,
|
|
email: true,
|
|
role: true,
|
|
createdAt: true
|
|
},
|
|
orderBy: {
|
|
createdAt: 'asc'
|
|
}
|
|
});
|
|
|
|
if (admins.length === 0) {
|
|
console.log('未找到管理员账号');
|
|
} else {
|
|
console.log(`找到 ${admins.length} 个管理员账号:\n`);
|
|
admins.forEach((admin, index) => {
|
|
console.log(`${index + 1}. 账号信息:`);
|
|
console.log(` ID: ${admin.id}`);
|
|
console.log(` 用户名: ${admin.username}`);
|
|
console.log(` 姓名: ${admin.name || '未设置'}`);
|
|
console.log(` 邮箱: ${admin.email || '未设置'}`);
|
|
console.log(` 角色: ${admin.role}`);
|
|
console.log(` 创建时间: ${admin.createdAt}`);
|
|
console.log('');
|
|
});
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('查询失败:', error.message);
|
|
process.exit(1);
|
|
} finally {
|
|
await prisma.$disconnect();
|
|
}
|
|
}
|
|
|
|
main();
|
|
|