42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.getEmailsByCustomerId = getEmailsByCustomerId;
|
|
exports.getEmailById = getEmailById;
|
|
exports.createEmail = createEmail;
|
|
exports.updateEmail = updateEmail;
|
|
exports.deleteEmail = deleteEmail;
|
|
const client_1 = require("@prisma/client");
|
|
const prisma = new client_1.PrismaClient();
|
|
async function getEmailsByCustomerId(customerId, includeInactive = false) {
|
|
const where = { customerId };
|
|
if (!includeInactive) {
|
|
where.isActive = true;
|
|
}
|
|
return prisma.stressfreiEmail.findMany({
|
|
where,
|
|
orderBy: { createdAt: 'desc' },
|
|
});
|
|
}
|
|
async function getEmailById(id) {
|
|
return prisma.stressfreiEmail.findUnique({
|
|
where: { id },
|
|
});
|
|
}
|
|
async function createEmail(data) {
|
|
return prisma.stressfreiEmail.create({
|
|
data: {
|
|
...data,
|
|
isActive: true,
|
|
},
|
|
});
|
|
}
|
|
async function updateEmail(id, data) {
|
|
return prisma.stressfreiEmail.update({
|
|
where: { id },
|
|
data,
|
|
});
|
|
}
|
|
async function deleteEmail(id) {
|
|
return prisma.stressfreiEmail.delete({ where: { id } });
|
|
}
|
|
//# sourceMappingURL=stressfreiEmail.service.js.map
|