@balena/abstract-sql-to-typescript
Advanced tools
Comparing version 1.0.3-lookup-referenced-data-type-f5def75cf04efec72ef1d8b6e3ee0c3c51b36019 to 1.0.3
{ | ||
"name": "@balena/abstract-sql-to-typescript", | ||
"version": "1.0.3-lookup-referenced-data-type-f5def75cf04efec72ef1d8b6e3ee0c3c51b36019", | ||
"version": "1.0.3", | ||
"description": "A translator for abstract sql into typescript types.", | ||
@@ -5,0 +5,0 @@ "main": "out/index.js", |
@@ -34,3 +34,3 @@ import { AbstractSqlModel } from '@balena/abstract-sql-compiler'; | ||
tables: { | ||
test: { | ||
parent: { | ||
fields: [ | ||
@@ -55,26 +55,43 @@ { | ||
}, | ||
], | ||
primitive: false, | ||
name: 'parent', | ||
indexes: [], | ||
idField: 'id', | ||
resourceName: 'parent', | ||
triggers: [ | ||
{ | ||
dataType: 'ConceptType', | ||
fieldName: 'parent', | ||
when: 'BEFORE', | ||
operation: 'UPDATE', | ||
level: 'ROW', | ||
fnName: 'trigger_update_modified_at', | ||
}, | ||
], | ||
}, | ||
other: { | ||
fields: [ | ||
{ | ||
dataType: 'Date Time', | ||
fieldName: 'created at', | ||
required: true, | ||
references: { | ||
resourceName: 'parent', | ||
fieldName: 'id', | ||
}, | ||
defaultValue: 'CURRENT_TIMESTAMP', | ||
}, | ||
{ | ||
dataType: 'ForeignKey', | ||
fieldName: 'referenced', | ||
dataType: 'Date Time', | ||
fieldName: 'modified at', | ||
required: true, | ||
references: { | ||
resourceName: 'referenced', | ||
fieldName: 'id', | ||
}, | ||
defaultValue: 'CURRENT_TIMESTAMP', | ||
}, | ||
{ | ||
dataType: 'Serial', | ||
fieldName: 'id', | ||
required: true, | ||
index: 'PRIMARY KEY', | ||
}, | ||
], | ||
primitive: false, | ||
name: 'test', | ||
name: 'other', | ||
indexes: [], | ||
idField: 'id', | ||
resourceName: 'test', | ||
resourceName: 'other', | ||
triggers: [ | ||
@@ -89,5 +106,17 @@ { | ||
}, | ||
referenced: { | ||
test: { | ||
fields: [ | ||
{ | ||
dataType: 'Date Time', | ||
fieldName: 'created at', | ||
required: true, | ||
defaultValue: 'CURRENT_TIMESTAMP', | ||
}, | ||
{ | ||
dataType: 'Date Time', | ||
fieldName: 'modified at', | ||
required: true, | ||
defaultValue: 'CURRENT_TIMESTAMP', | ||
}, | ||
{ | ||
dataType: 'Serial', | ||
@@ -98,8 +127,26 @@ fieldName: 'id', | ||
}, | ||
{ | ||
dataType: 'ConceptType', | ||
fieldName: 'parent', | ||
required: true, | ||
references: { | ||
resourceName: 'parent', | ||
fieldName: 'id', | ||
}, | ||
}, | ||
{ | ||
dataType: 'ForeignKey', | ||
fieldName: 'references-other', | ||
required: true, | ||
references: { | ||
resourceName: 'other', | ||
fieldName: 'id', | ||
}, | ||
}, | ||
], | ||
primitive: false, | ||
name: 'referenced', | ||
name: 'test', | ||
indexes: [], | ||
idField: 'id', | ||
resourceName: 'referenced', | ||
resourceName: 'test', | ||
triggers: [ | ||
@@ -121,13 +168,21 @@ { | ||
source` | ||
export interface Test { | ||
export interface Parent { | ||
created_at: DateString; | ||
modified_at: DateString; | ||
id: number; | ||
parent: number; | ||
referenced: { __id: number } | [Referenced]; | ||
} | ||
export interface Referenced { | ||
export interface Other { | ||
created_at: DateString; | ||
modified_at: DateString; | ||
id: number; | ||
} | ||
export interface Test { | ||
created_at: DateString; | ||
modified_at: DateString; | ||
id: number; | ||
parent: number; | ||
references__other: { __id: number } | [Other]; | ||
} | ||
`, | ||
@@ -140,15 +195,23 @@ ); | ||
source` | ||
export interface Test { | ||
export interface Parent { | ||
created_at: Date; | ||
modified_at: Date; | ||
id: number; | ||
parent: number; | ||
referenced: number; | ||
} | ||
export interface Referenced { | ||
export interface Other { | ||
created_at: Date; | ||
modified_at: Date; | ||
id: number; | ||
} | ||
export interface Test { | ||
created_at: Date; | ||
modified_at: Date; | ||
id: number; | ||
parent: number; | ||
references__other: number; | ||
} | ||
`, | ||
'write', | ||
); |
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
18190
453
1