2
0
Files
bot/packages/scripts/index.ts

50 lines
980 B
TypeScript
Raw Normal View History

import { PrismaClient } from 'db'
2022-02-25 09:45:31 +01:00
import path from 'path'
const prisma = new PrismaClient({
log: [
{
emit: 'event',
level: 'query',
},
{
emit: 'stdout',
level: 'error',
},
{
emit: 'stdout',
level: 'info',
},
{
emit: 'stdout',
level: 'warn',
},
],
})
2022-02-25 09:45:31 +01:00
require('dotenv').config({
path: path.join(
__dirname,
process.env.NODE_ENV === 'production'
? '.env.production'
: process.env.NODE_ENV === 'staging'
? '.env.staging'
: '.env.local'
2022-02-25 09:45:31 +01:00
),
})
2022-05-13 15:22:44 -07:00
const main = async () => {
prisma.$on('query', (e) => {
console.log('Query: ' + e.query)
console.log('Params: ' + e.params)
console.log('Duration: ' + e.duration + 'ms')
})
const date = new Date()
const lastMonth = new Date(date.getFullYear(), date.getMonth() - 1, 10)
const answers = await prisma.answer.findMany({
where: { createdAt: { lt: lastMonth } },
take: 100,
})
2022-05-13 15:22:44 -07:00
}
2022-02-25 09:45:31 +01:00
main().then()