@@ -2,29 +2,7 @@ import { ident, literal } from 'pg-format'
22import PostgresMetaTables from './PostgresMetaTables'
33import { DEFAULT_SYSTEM_SCHEMAS } from './constants'
44import { columnsSql } from './sql'
5- import { PostgresMetaResult , PostgresColumn } from './types'
6-
7- interface ColumnCreationRequest {
8- table_id : number
9- name : string
10- type : string
11- default_value ?: any
12- default_value_format ?: 'expression' | 'literal'
13- is_identity ?: boolean
14- identity_generation ?: 'BY DEFAULT' | 'ALWAYS'
15- is_nullable ?: boolean
16- is_primary_key ?: boolean
17- is_unique ?: boolean
18- comment ?: string
19- check ?: string
20- }
21-
22- interface ColumnBatchInfoRequest {
23- ids ?: string [ ]
24- names ?: string [ ]
25- table ?: string
26- schema ?: string
27- }
5+ import { PostgresMetaResult , PostgresColumn , PostgresColumnCreate } from './types'
286
297export default class PostgresMetaColumns {
308 query : ( sql : string ) => Promise < PostgresMetaResult < any > >
@@ -97,12 +75,27 @@ export default class PostgresMetaColumns {
9775 return { data : null , error : { message : 'Invalid parameters on column retrieve' } }
9876 }
9977
78+ async batchRetrieve ( { ids } : { ids : string [ ] } ) : Promise < PostgresMetaResult < PostgresColumn [ ] > >
79+ async batchRetrieve ( {
80+ names,
81+ table,
82+ schema,
83+ } : {
84+ names : string [ ]
85+ table : string
86+ schema : string
87+ } ) : Promise < PostgresMetaResult < PostgresColumn [ ] > >
10088 async batchRetrieve ( {
10189 ids,
10290 names,
10391 table,
10492 schema = 'public' ,
105- } : ColumnBatchInfoRequest ) : Promise < PostgresMetaResult < PostgresColumn [ ] > > {
93+ } : {
94+ ids ?: string [ ]
95+ names ?: string [ ]
96+ table ?: string
97+ schema ?: string
98+ } ) : Promise < PostgresMetaResult < PostgresColumn [ ] > > {
10699 if ( ids && ids . length > 0 ) {
107100 const regexp = / ^ ( \d + ) \. ( \d + ) $ /
108101 const filteringClauses = ids
@@ -145,7 +138,7 @@ export default class PostgresMetaColumns {
145138 }
146139 }
147140
148- async create ( col : ColumnCreationRequest ) : Promise < PostgresMetaResult < PostgresColumn > > {
141+ async create ( col : PostgresColumnCreate ) : Promise < PostgresMetaResult < PostgresColumn > > {
149142 const { data, error } = await this . batchCreate ( [ col ] )
150143 if ( data ) {
151144 return { data : data [ 0 ] , error : null }
@@ -155,7 +148,7 @@ export default class PostgresMetaColumns {
155148 return { data : null , error : { message : 'Invalid params' } }
156149 }
157150
158- async batchCreate ( cols : ColumnCreationRequest [ ] ) : Promise < PostgresMetaResult < PostgresColumn [ ] > > {
151+ async batchCreate ( cols : PostgresColumnCreate [ ] ) : Promise < PostgresMetaResult < PostgresColumn [ ] > > {
159152 if ( cols . length < 1 ) {
160153 throw new Error ( 'no columns provided for creation' )
161154 }
@@ -199,7 +192,7 @@ COMMIT;
199192 is_unique = false ,
200193 comment,
201194 check,
202- } : ColumnCreationRequest ,
195+ } : PostgresColumnCreate ,
203196 schema : string ,
204197 table : string
205198 ) {
0 commit comments