Change a type into what would be returned from the database
e.g. any object or array will be returned as a JSON string, except Date which is returned from the Database by default.
To convert dates to strings as well, pass true into the second template parameter
true
To convert objects/arrays into something other than strings, use the third template parameter to set what they will be returned as
type Foo = { a: number; b?: string[]; c: { id: number, value: string }; d: Date;}type FooDB = ToDBType<Foo>;//=> {// a: number;// b: string | null;// c: string;// d: Date;//} Copy
type Foo = { a: number; b?: string[]; c: { id: number, value: string }; d: Date;}type FooDB = ToDBType<Foo>;//=> {// a: number;// b: string | null;// c: string;// d: Date;//}
Change a type into what would be returned from the database
e.g. any object or array will be returned as a JSON string, except Date which is returned from the Database by default.
To convert dates to strings as well, pass
trueinto the second template parameterTo convert objects/arrays into something other than strings, use the third template parameter to set what they will be returned as