source: app/lib/definitions.ts

nextjs
Last change on this file was dd96867, checked in by Vasilaki Tocili <vasilakigorgi@…>, 4 months ago

feature: add database definitions

  • Property mode set to 100644
File size: 1.5 KB
Line 
1// This file contains type definitions for the data.
2// It describes the shape of the data, and what data type each property should accept.
3
4export type User = {
5 user_id: number;
6 user_name: string;
7 email: string;
8 password: string; // hashed
9};
10
11export type TransactionAccount = {
12 transaction_account_id: number;
13 account_name: string | null;
14 balance: string; // DECIMAL comes back as string with `postgres` driver
15 user_id: number | null;
16};
17
18export type Transaction = {
19 transaction_id: number;
20 transaction_name: string | null;
21 amount: string; // DECIMAL -> string
22 net_amount: string | null; // DECIMAL -> string
23 date: string; // TIMESTAMPTZ -> ISO string
24};
25
26export type Tag = {
27 tag_id: number;
28 tag_name: string;
29};
30
31export type TagAssignedToTransaction = {
32 tag_assigned_to_transaction_id: number;
33 transaction_id: number;
34 tag_id: number;
35};
36
37export type TransactionBreakdown = {
38 transaction_breakdown_id: number;
39 transaction_id: number | null;
40 transaction_account_id: number | null;
41 spent_amount: string | null; // DECIMAL -> string
42 earned_amount: string | null; // DECIMAL -> string
43};
44
45/**
46 * Useful “joined/view” shapes (not tables).
47 * These make UI and API code nicer.
48 */
49
50export type TransactionWithTags = Transaction & {
51 tags: Tag[];
52};
53
54export type TransactionAccountWithBreakdowns = TransactionAccount & {
55 breakdowns: TransactionBreakdown[];
56};
57
58export type TransactionBreakdownResolved = TransactionBreakdown & {
59 transaction?: Transaction;
60 transaction_account?: TransactionAccount;
61};
Note: See TracBrowser for help on using the repository browser.