Posts

Showing posts from March 22, 2019

Database module on TypeScript. Too many type definitions

Image
0 Core Review Hello, I'm developing relatively simple car rental service app. I decided to use TypeScript for backend. The question is about database module. Now there are three entities: car , tariff и photo . I use MongoDB as database. General types are extracted tp separate file src/lib/types.ts : // Currency export enum Currency { USD = "USD", EUR = "EUR", } // Price export interface Price { value: number; currency: Currency; } // DB Entity export interface Entity { id: string; createdAt: Date; } // Tariff export interface TariffCreateFields { days: number; currency: Currency; price: number; } export interface Tariff extends Entity { days: number; currency: Currency; price: number; } // Photo export interf