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, }