neat tool - why use namespaces? just curious
ORESoftware opened this issue · 1 comments
ORESoftware commented
This worked fine for me so far. Just curious why the use for namespaces?
when I ran this:
schemats generate -c 'postgres://postgres:postgres@localhost/postgres' -t 'user_table' -o schemas/user.ts
I got:
export namespace user_tableFields {
export type id = number;
export type handle = string;
export type email = string;
export type first_name = string;
export type last_name = string;
export type is_verified = boolean;
}
export interface user_table {
id: user_tableFields.id;
handle: user_tableFields.handle;
email: user_tableFields.email;
first_name: user_tableFields.first_name;
last_name: user_tableFields.last_name;
is_verified: user_tableFields.is_verified;
}
HoldYourWaffle commented
Because it enables you to reference column types:
export namespace user_tableFields {
export type id = number;
...
}
export namespace post_tableFields {
export type id = number;
...
}
export interface MyUser {
id: user_tableFields.id;
posts: post_tableFields.id[];
}
I haven't used this library in a while and this isn't a very pretty example, but I hope it can clear up some confusion.