schema-typegen
Advanced tools
Comparing version 2.5.4 to 2.6.0
@@ -30,2 +30,4 @@ Usage: schema-typegen [opts] connection_string | ||
Use bigint for int8 types instead of strings. Default: false. | ||
--date-as-string | ||
Use string for date types instead of javascript Date object. Default: false. | ||
-v/--version | ||
@@ -32,0 +34,0 @@ Print the version number. |
@@ -11,3 +11,3 @@ 'use strict' | ||
object: ['json', 'jsonb'], | ||
Date: ['date', 'timestamp', 'timestamptz'], | ||
Date: ['timestamp', 'timestamptz'], | ||
'Array<string>': ['_bpchar', '_char', '_varchar', '_text', '_uuid', '_bytea', '_inet', '_int8', '_time', '_timetz', '_interval', '_name'], | ||
@@ -17,3 +17,3 @@ 'Array<number>': ['_int2', '_int4', '_float4', '_float8', '_numeric', '_money', '_oid'], | ||
'Array<object>': ['_json', '_jsonb'], | ||
'Array<Date>': ['_date', '_timestamp', '_timestamptz'] | ||
'Array<Date>': ['_timestamp', '_timestamptz'] | ||
} | ||
@@ -53,3 +53,3 @@ | ||
async function getSchemaDefinition (opts) { | ||
const { schema, connection, bigint } = opts | ||
const { schema, connection, bigint, dateAsString } = opts | ||
@@ -62,2 +62,10 @@ if (bigint) { | ||
if (dateAsString) { | ||
typeMapping.string.push('date') | ||
typeMapping['Array<string>'].push('_date') | ||
} else { | ||
typeMapping.Date.push('date') | ||
typeMapping['Array<Date>'].push('_date') | ||
} | ||
const sql = postgres(connection, getPostgresOpts(opts)) | ||
@@ -64,0 +72,0 @@ try { |
{ | ||
"name": "schema-typegen", | ||
"version": "2.5.4", | ||
"version": "2.6.0", | ||
"description": "Generate TypeScript type definitions from database schema", | ||
@@ -5,0 +5,0 @@ "main": "schema-typegen.js", |
@@ -11,2 +11,3 @@ declare module 'schema-typegen' { | ||
bigint?: boolean; | ||
dateAsString?: boolean; | ||
schema?: string; | ||
@@ -13,0 +14,0 @@ output?: string; |
@@ -21,2 +21,3 @@ #! /usr/bin/env node | ||
bigint: false, | ||
dateAsString: false, | ||
schema: 'public', | ||
@@ -30,3 +31,3 @@ output: undefined, | ||
const argv = minimist(argvs, { | ||
boolean: ['type', 'noSemi', 'bigint', 'semicolons', 'version', 'optionals', 'ssl', 'pascal-enums'], | ||
boolean: ['type', 'noSemi', 'bigint', 'date-as-string', 'semicolons', 'version', 'optionals', 'ssl', 'pascal-enums'], | ||
alias: { | ||
@@ -33,0 +34,0 @@ suffix: 'f', |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15964
285