This repository has been archived on 2026-01-31. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
nodejs-template-with-typesc…/src/database/database.ts
Riccardo Senica 392e0db67b Prisma (#2)
feat: added Prisma
2023-08-05 17:23:34 +02:00

33 lines
747 B
TypeScript

import { PrismaClient } from '@prisma/client';
import { randomUUID } from 'crypto';
const prisma = new PrismaClient();
/**
* Create a new record in the Addition table.
* @param value - The value number to add as a new record.
* @returns Whether the database operation succeeded.
*/
export async function createAddition(value: number) {
return await prisma.addition.create({
data: {
id: randomUUID(),
datetime: new Date(),
value
}
});
}
/**
* Retrieve a record from the Addition table.
* @param id - The id of the record.
* @returns The retrieved record, or an error.
*/
export async function readAddition(id: string) {
return await prisma.addition.findUniqueOrThrow({
where: {
id
}
});
}