@@ -73,7 +73,7 @@ export class DocumentSubscriptions implements IDisposable {
7373 throwError ( "InvalidArgumentException" , "Cannot create a subscription if the script is null" ) ;
7474 }
7575
76- const requestExecutor = this . _store . getRequestExecutor ( database || this . _store . database ) ;
76+ const requestExecutor = this . _store . getRequestExecutor ( this . _store . getEffectiveDatabase ( database ) ) ;
7777
7878 const command = new CreateSubscriptionCommand ( options ) ;
7979 await requestExecutor . execute ( command ) ;
@@ -322,7 +322,7 @@ export class DocumentSubscriptions implements IDisposable {
322322 * It downloads a list of all existing subscriptions in a database.
323323 */
324324 public async getSubscriptions ( start : number , take : number , database ?: string ) : Promise < SubscriptionState [ ] > {
325- const requestExecutor = this . _store . getRequestExecutor ( database || this . _store . database ) ;
325+ const requestExecutor = this . _store . getRequestExecutor ( this . _store . getEffectiveDatabase ( database ) ) ;
326326
327327 const command = new GetSubscriptionsCommand ( start , take ) ;
328328 await requestExecutor . execute ( command ) ;
@@ -344,7 +344,7 @@ export class DocumentSubscriptions implements IDisposable {
344344 * Delete a subscription.
345345 */
346346 public async delete ( name : string , database ?: string ) : Promise < void > {
347- const requestExecutor = this . _store . getRequestExecutor ( database || this . _store . database ) ;
347+ const requestExecutor = this . _store . getRequestExecutor ( this . _store . getEffectiveDatabase ( database ) ) ;
348348
349349 const command = new DeleteSubscriptionCommand ( name ) ;
350350 return requestExecutor . execute ( command ) ;
@@ -368,7 +368,7 @@ export class DocumentSubscriptions implements IDisposable {
368368 throwError ( "InvalidArgumentException" , "SubscriptionName cannot be null" ) ;
369369 }
370370
371- const requestExecutor = this . _store . getRequestExecutor ( database || this . _store . database ) ;
371+ const requestExecutor = this . _store . getRequestExecutor ( this . _store . getEffectiveDatabase ( database ) ) ;
372372
373373 const command = new GetSubscriptionStateCommand ( subscriptionName ) ;
374374 await requestExecutor . execute ( command ) ;
@@ -397,7 +397,7 @@ export class DocumentSubscriptions implements IDisposable {
397397 * Force server to close current client subscription connection to the server
398398 */
399399 public async dropConnection ( name : string , database ?: string ) : Promise < void > {
400- const requestExecutor = this . _store . getRequestExecutor ( database || this . _store . database ) ;
400+ const requestExecutor = this . _store . getRequestExecutor ( this . _store . getEffectiveDatabase ( database ) ) ;
401401
402402 const command = new DropSubscriptionConnectionCommand ( name ) ;
403403 return requestExecutor . execute ( command ) ;
@@ -407,15 +407,15 @@ export class DocumentSubscriptions implements IDisposable {
407407 public async enable ( name : string , database : string )
408408 public async enable ( name : string , database ?: string ) {
409409 const operation = new ToggleOngoingTaskStateOperation ( name , "Subscription" , false ) ;
410- await this . _store . maintenance . forDatabase ( database || this . _store . database )
410+ await this . _store . maintenance . forDatabase ( this . _store . getEffectiveDatabase ( database ) )
411411 . send ( operation ) ;
412412 }
413413
414414 public async disable ( name : string )
415415 public async disable ( name : string , database : string )
416416 public async disable ( name : string , database ?: string ) {
417417 const operation = new ToggleOngoingTaskStateOperation ( name , "Subscription" , true ) ;
418- await this . _store . maintenance . forDatabase ( database || this . _store . database )
418+ await this . _store . maintenance . forDatabase ( this . _store . getEffectiveDatabase ( database ) )
419419 . send ( operation ) ;
420420 }
421421
0 commit comments