@@ -646,7 +646,7 @@ export class PostgresStorageAdapter {
646
646
. then ( ( ) => this . _ensureSchemaCollectionExists ( ) )
647
647
. then ( ( ) => {
648
648
const values = [ className , 'schema' , 'indexes' , JSON . stringify ( existingIndexes ) ]
649
- return this . _client . none ( `UPDATE "_SCHEMA" SET $2:name = json_object_set_key($2:name, $3::text, $4::jsonb) WHERE "className"=$1 ` , values ) ;
649
+ return conn . none ( `UPDATE "_SCHEMA" SET $2:name = json_object_set_key($2:name, $3::text, $4::jsonb) WHERE "className"=$1 ` , values ) ;
650
650
} ) ;
651
651
}
652
652
@@ -1453,22 +1453,13 @@ export class PostgresStorageAdapter {
1453
1453
}
1454
1454
1455
1455
createIndexes ( className , indexes , conn ) {
1456
- conn = conn || this . _client ;
1457
- return conn . tx ( t => {
1458
- const batch = [ ] ;
1459
- indexes . forEach ( ( index ) => {
1460
- const fieldNames = Object . keys ( index . key ) ;
1461
- const pattern = fieldNames . map ( ( key , index ) => `$${ index + 3 } :name` ) ;
1462
- const qs = t . none ( `CREATE INDEX $1:name ON $2:name (${ pattern . join ( ',' ) } )` , [ index . name , className , ...fieldNames ] ) ;
1463
- batch . push ( qs ) ;
1464
- } ) ;
1465
- return t . batch ( batch ) ;
1466
- } ) ;
1456
+ return ( conn || this . _client ) . tx ( t => t . batch ( indexes . map ( i => {
1457
+ return t . none ( 'CREATE INDEX $1:name ON $2:name ($3:name)' , [ i . name , className , i . key ] ) ;
1458
+ } ) ) ) ;
1467
1459
}
1468
1460
1469
1461
dropIndexes ( className , indexes , conn ) {
1470
- conn = conn || this . _client ;
1471
- return conn . tx ( t => t . batch ( indexes . map ( i => t . none ( 'DROP INDEX $1:name' , i ) ) ) ) ;
1462
+ return ( conn || this . _client ) . tx ( t => t . batch ( indexes . map ( i => t . none ( 'DROP INDEX $1:name' , i ) ) ) ) ;
1472
1463
}
1473
1464
1474
1465
getIndexes ( className ) {
0 commit comments