HotTRDealsBackend/db/notification.db.js
2026-02-04 06:39:10 +00:00

28 lines
672 B
JavaScript

const prisma = require("./client")
function getDb(db) {
return db || prisma
}
async function findNotifications(where, options = {}, db) {
const p = getDb(db)
return p.notification.findMany({
where,
select: options.select || undefined,
include: options.include || undefined,
orderBy: options.orderBy || { createdAt: "desc" },
skip: Number.isInteger(options.skip) ? options.skip : undefined,
take: Number.isInteger(options.take) ? options.take : undefined,
})
}
async function countNotifications(where, db) {
const p = getDb(db)
return p.notification.count({ where })
}
module.exports = {
findNotifications,
countNotifications,
}