46 lines
1008 B
TypeScript
46 lines
1008 B
TypeScript
import { PrismaClient } from '@prisma/client';
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
const emails = await prisma.emailLog.findMany({
|
|
where: {
|
|
recipientEmail: 'abdelaziz.azouhri@gmail.com',
|
|
},
|
|
orderBy: {
|
|
sentAt: 'desc',
|
|
},
|
|
take: 10,
|
|
select: {
|
|
emailType: true,
|
|
status: true,
|
|
sentAt: true,
|
|
errorMessage: true,
|
|
subject: true,
|
|
},
|
|
});
|
|
|
|
console.log('\n=== Email Log ===');
|
|
console.log(`Found ${emails.length} emails\n`);
|
|
|
|
emails.forEach((email, index) => {
|
|
console.log(`${index + 1}. ${email.emailType}`);
|
|
console.log(` Status: ${email.status}`);
|
|
console.log(` Subject: ${email.subject}`);
|
|
console.log(` Sent At: ${email.sentAt}`);
|
|
if (email.errorMessage) {
|
|
console.log(` Error: ${email.errorMessage}`);
|
|
}
|
|
console.log('');
|
|
});
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect();
|
|
});
|