1
- import { google , Ydb } from "ydb-sdk-proto" ;
1
+ import { google , Ydb } from "ydb-sdk-proto" ;
2
2
import IQuery = Ydb . Table . IQuery ;
3
3
import IType = Ydb . IType ;
4
4
import DescribeTableResult = Ydb . Table . DescribeTableResult ;
@@ -19,15 +19,15 @@ import BulkUpsertResult = Ydb.Table.BulkUpsertResult;
19
19
import OperationMode = Ydb . Operations . OperationParams . OperationMode ;
20
20
import * as grpc from "@grpc/grpc-js" ;
21
21
import EventEmitter from "events" ;
22
- import { ICreateSessionResult , SessionEvent , TableService } from "./table-session-pool" ;
23
- import { Endpoint } from "../discovery" ;
24
- import { retryable , RetryParameters , RetryStrategy } from "../retries_obsoleted" ;
25
- import { MissingStatus , MissingValue , SchemeError , YdbError } from "../errors" ;
26
- import { ResponseMetadataKeys } from "../constants" ;
27
- import { pessimizable } from "../utils" ;
28
- import { YdbOperationAsyncResponse , ensureOperationSucceeded , getOperationPayload } from "../utils/process-ydb-operation-result" ;
29
- import { StreamEnd } from "../utils" ;
30
- import { Logger } from "../logger/simple-logger" ;
22
+ import { ICreateSessionResult , SessionEvent , TableService } from "./table-session-pool" ;
23
+ import { Endpoint } from "../discovery" ;
24
+ import { retryable , RetryParameters , RetryStrategy } from "../retries_obsoleted" ;
25
+ import { MissingStatus , MissingValue , SchemeError , YdbError } from "../errors" ;
26
+ import { ResponseMetadataKeys } from "../constants" ;
27
+ import { pessimizable } from "../utils" ;
28
+ import { YdbOperationAsyncResponse , ensureOperationSucceeded , getOperationPayload } from "../utils/process-ydb-operation-result" ;
29
+ import { StreamEnd } from "../utils" ;
30
+ import { Logger } from "../logger/simple-logger" ;
31
31
32
32
interface PartialResponse < T > {
33
33
status ?: ( Ydb . StatusIds . StatusCode | null ) ;
@@ -78,7 +78,7 @@ export class OperationParams implements Ydb.Operations.IOperationParams {
78
78
}
79
79
80
80
withOperationTimeoutSeconds ( seconds : number ) {
81
- this . operationTimeout = { seconds} ;
81
+ this . operationTimeout = { seconds } ;
82
82
return this ;
83
83
}
84
84
@@ -88,7 +88,7 @@ export class OperationParams implements Ydb.Operations.IOperationParams {
88
88
}
89
89
90
90
withCancelAfterSeconds ( seconds : number ) {
91
- this . cancelAfter = { seconds} ;
91
+ this . cancelAfter = { seconds } ;
92
92
return this ;
93
93
}
94
94
@@ -125,7 +125,7 @@ interface IDropTableSettings {
125
125
export class DropTableSettings extends OperationParamsSettings {
126
126
muteNonExistingTableErrors : boolean ;
127
127
128
- constructor ( { muteNonExistingTableErrors = true } = { } as IDropTableSettings ) {
128
+ constructor ( { muteNonExistingTableErrors = true } = { } as IDropTableSettings ) {
129
129
super ( ) ;
130
130
this . muteNonExistingTableErrors = muteNonExistingTableErrors ;
131
131
}
@@ -312,13 +312,13 @@ export class TableSession extends EventEmitter implements ICreateSessionResult {
312
312
return Promise . resolve ( ) ;
313
313
}
314
314
this . beingDeleted = true ;
315
- ensureOperationSucceeded ( await this . api . deleteSession ( { sessionId : this . sessionId } ) ) ;
315
+ ensureOperationSucceeded ( await this . api . deleteSession ( { sessionId : this . sessionId } ) ) ;
316
316
}
317
317
318
318
@retryable ( )
319
319
@pessimizable
320
320
public async keepAlive ( ) : Promise < void > {
321
- const request = { sessionId : this . sessionId } ;
321
+ const request = { sessionId : this . sessionId } ;
322
322
const response = await this . api . keepAlive ( request ) ;
323
323
ensureOperationSucceeded ( this . processResponseMetadata ( request , response ) ) ;
324
324
}
@@ -439,7 +439,7 @@ export class TableSession extends EventEmitter implements ICreateSessionResult {
439
439
}
440
440
const response = await this . api . beginTransaction ( request ) ;
441
441
const payload = getOperationPayload ( this . processResponseMetadata ( request , response ) ) ;
442
- const { txMeta} = BeginTransactionResult . decode ( payload ) ;
442
+ const { txMeta } = BeginTransactionResult . decode ( payload ) ;
443
443
if ( txMeta ) {
444
444
return txMeta ;
445
445
}
@@ -524,15 +524,15 @@ export class TableSession extends EventEmitter implements ICreateSessionResult {
524
524
request . collectStats = settings . collectStats ;
525
525
}
526
526
if ( keepInCache ) {
527
- request . queryCachePolicy = { keepInCache} ;
527
+ request . queryCachePolicy = { keepInCache } ;
528
528
}
529
529
530
530
if ( ! executeQueryRetryer ) executeQueryRetryer = new RetryStrategy ( 'TableSession:executeQuery' , new RetryParameters ( ) , this . logger ) ;
531
531
532
532
const response =
533
533
settings ?. idempotent
534
- ? await executeQueryRetryer . retry ( ( ) => this . api . executeDataQuery ( request ) )
535
- : await this . api . executeDataQuery ( request ) ;
534
+ ? await executeQueryRetryer . retry ( ( ) => this . api . executeDataQuery ( request ) )
535
+ : await this . api . executeDataQuery ( request ) ;
536
536
const payload = getOperationPayload ( this . processResponseMetadata ( request , response , settings ?. onResponseMetadata ) ) ;
537
537
return ExecuteQueryResult . decode ( payload ) ;
538
538
}
@@ -887,6 +887,7 @@ export class TableIndex implements Ydb.Table.ITableIndex {
887
887
public dataColumns : string [ ] | null = null ;
888
888
public globalIndex : Ydb . Table . IGlobalIndex | null = null ;
889
889
public globalAsyncIndex : Ydb . Table . IGlobalAsyncIndex | null = null ;
890
+ public globalUniqueIndex : Ydb . Table . IGlobalUniqueIndex | null = null ;
890
891
891
892
constructor ( public name : string ) {
892
893
}
@@ -913,13 +914,20 @@ export class TableIndex implements Ydb.Table.ITableIndex {
913
914
}
914
915
return this
915
916
}
917
+
918
+ withGlobalUnique ( ) {
919
+ this . globalUniqueIndex = new Ydb . Table . GlobalUniqueIndex ( )
920
+ this . globalAsyncIndex = null
921
+ this . globalIndex = null
922
+ return this
923
+ }
916
924
}
917
925
918
926
export class TtlSettings implements Ydb . Table . ITtlSettings {
919
927
public dateTypeColumn ?: Ydb . Table . IDateTypeColumnModeSettings | null ;
920
928
921
929
constructor ( columnName : string , expireAfterSeconds : number = 0 ) {
922
- this . dateTypeColumn = { columnName, expireAfterSeconds} ;
930
+ this . dateTypeColumn = { columnName, expireAfterSeconds } ;
923
931
}
924
932
}
925
933
0 commit comments