schema-typegen
Advanced tools
Comparing version 2.3.0 to 2.4.0
@@ -28,2 +28,4 @@ Usage: schema-typegen [opts] connection_string | ||
Transform enum keys to pascal case. Default: false. | ||
--bigint | ||
Use bigint for int8 types instead of strings. Default: false. | ||
-v/--version | ||
@@ -30,0 +32,0 @@ Print the version number. |
@@ -6,5 +6,6 @@ 'use strict' | ||
const typeMapping = { | ||
string: ['bpchar', 'char', 'varchar', 'text', 'uuid', 'bytea', 'inet', 'int8', 'time', 'timetz', 'interval', 'name'], | ||
string: ['bpchar', 'char', 'varchar', 'text', 'uuid', 'bytea', 'inet', 'time', 'timetz', 'interval', 'name'], | ||
number: ['int2', 'int4', 'float4', 'float8', 'numeric', 'money', 'oid'], | ||
boolean: ['bool'], | ||
bigint: [], | ||
object: ['json', 'jsonb'], | ||
@@ -51,3 +52,10 @@ Date: ['date', 'timestamp', 'timestamptz'], | ||
async function getSchemaDefinition (opts) { | ||
const { schema, connection } = opts | ||
const { schema, connection, bigint } = opts | ||
if (bigint) { | ||
typeMapping.bigint.push('int8') | ||
} else { | ||
typeMapping.string.push('int8') | ||
} | ||
const sql = postgres(connection, getPostgresOpts(opts)) | ||
@@ -54,0 +62,0 @@ try { |
{ | ||
"name": "schema-typegen", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"description": "Generate TypeScript type definitions from database schema", | ||
@@ -10,3 +10,4 @@ "main": "schema-typegen.js", | ||
"scripts": { | ||
"test": "standard && tap test/*.js --100 --before=test/helpers/setup-postgres.js", | ||
"test": "tap test/*.js --100 --before=test/helpers/setup-postgres.js", | ||
"lint": "standard", | ||
"lint:fix": "standard --fix" | ||
@@ -13,0 +14,0 @@ }, |
@@ -59,2 +59,4 @@ <h1 align="center">Welcome to schema-typegen 👋</h1> | ||
Transform enum keys to pascal case. Default: false. | ||
--bigint | ||
Use bigint for int8 types instead of strings. Default: false. | ||
-v/--version | ||
@@ -61,0 +63,0 @@ Print the version number. |
@@ -20,2 +20,3 @@ #! /usr/bin/env node | ||
pascalEnums: false, | ||
bigint: false, | ||
schema: 'public', | ||
@@ -29,3 +30,3 @@ output: undefined, | ||
const argv = minimist(argvs, { | ||
boolean: ['type', 'noSemi', 'semicolons', 'version', 'optionals', 'ssl', 'pascal-enums'], | ||
boolean: ['type', 'noSemi', 'bigint', 'semicolons', 'version', 'optionals', 'ssl', 'pascal-enums'], | ||
alias: { | ||
@@ -32,0 +33,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
14261
234
128