Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support more PG types #4

Merged
merged 1 commit into from
Mar 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion packages/cli/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,48 @@ import { debug } from "./util";
export enum FieldType {
String = "string",
Number = "number",
Bool = "boolean",
Date = "Date",
}

const typeMap: {
[pgTypeName: string]: string;
} = {
uuid: FieldType.String,
// Integer types
int2: FieldType.Number,
int4: FieldType.Number,
int8: FieldType.Number,
smallint: FieldType.Number,
int: FieldType.Number,
bigint: FieldType.Number,

// Precision types
real: FieldType.Number,
float4: FieldType.Number,
float: FieldType.Number,
float8: FieldType.Number,
numeric: FieldType.Number,
decimal: FieldType.Number,

// Serial types
smallserial: FieldType.Number,
serial: FieldType.Number,
bigserial: FieldType.Number,

// Common string types
uuid: FieldType.String,
text: FieldType.String,
varchar: FieldType.String,
char: FieldType.String,

// Bool types
bit: FieldType.Bool, // TODO: better bit array support
bool: FieldType.Bool,
boolean: FieldType.Bool,

// Extra types
date: FieldType.Date,
money: FieldType.Number,
};

export interface IField {
Expand Down