aboutsummaryrefslogtreecommitdiff
path: root/src/service/transaction.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/service/transaction.ts')
-rw-r--r--src/service/transaction.ts24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/service/transaction.ts b/src/service/transaction.ts
index 29a9faa..8f1c99d 100644
--- a/src/service/transaction.ts
+++ b/src/service/transaction.ts
@@ -42,7 +42,29 @@ const read = async (userId: Number, type: String) => {
})
}
+// TODO: ig collaborated transactions would need more logic
+const del = async (userId: Number, transactionId: String) => {
+ const t = await prisma.transaction.findUnique({
+ // @ts-ignore
+ where: { id: transactionId }
+ })
+
+ if (t) {
+ if (t.userId == userId) {
+ return prisma.transaction.delete({
+ // @ts-ignore
+ where: { id: transactionId }
+ })
+ } else {
+ throw new Error("403")
+ }
+ } else {
+ throw new Error("404")
+ }
+}
+
export {
create,
- read
+ read,
+ del
}