Add sql param logic.

This commit is contained in:
Brian Cao 2023-01-16 12:58:51 -08:00
parent cc46cfdcbf
commit d93c2f9dd7
9 changed files with 46 additions and 32 deletions

View file

@ -36,6 +36,18 @@ function logQuery(e) {
log(chalk.yellow(e.params), '->', e.query, chalk.greenBright(`${e.duration}ms`));
}
function toUuid() {
const db = getDatabaseType(process.env.DATABASE_URL);
if (db === POSTGRESQL) {
return '::uuid';
}
if (db === MYSQL) {
return '';
}
}
function getClient(options) {
const prisma = new PrismaClient(options);
@ -248,6 +260,7 @@ const prisma = global[PRISMA] || getClient(PRISMA_OPTIONS);
export default {
client: prisma,
log,
toUuid,
getDateQuery,
getTimestampInterval,
getFilterQuery,