@wepublish/api
Version:
API core for we.publish.
63 lines • 2.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConsentService = void 0;
const tslib_1 = require("tslib");
const common_1 = require("@nestjs/common");
const client_1 = require("@prisma/client");
let ConsentService = exports.ConsentService = class ConsentService {
constructor(prisma) {
this.prisma = prisma;
}
consentList(filter) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const data = yield this.prisma.consent.findMany({
where: Object.assign({}, filter),
orderBy: {
createdAt: 'desc'
}
});
return data;
});
}
consent(id) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const data = yield this.prisma.consent.findUnique({
where: {
id
}
});
if (!data) {
throw new common_1.NotFoundException(`Consent with id ${id} not found`);
}
return data;
});
}
createConsent(consent) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return yield this.prisma.consent.create({ data: consent });
});
}
updateConsent(_a) {
var { id } = _a, consent = tslib_1.__rest(_a, ["id"]);
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const updated = yield this.prisma.consent.update({
where: { id },
data: Object.assign({}, consent)
});
return updated;
});
}
deleteConsent(id) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const deleted = this.prisma.consent.delete({
where: { id }
});
return deleted;
});
}
};
exports.ConsentService = ConsentService = tslib_1.__decorate([
(0, common_1.Injectable)(),
tslib_1.__metadata("design:paramtypes", [client_1.PrismaClient])
], ConsentService);
//# sourceMappingURL=consent.service.js.map