@@ -71,7 +71,7 @@ export class DocumentSubscriptions implements IDisposable {
7171 throwError ( "InvalidArgumentException" , "Cannot create a subscription if the script is null" ) ;
7272 }
7373
74- const requestExecutor = this . _store . getRequestExecutor ( database || this . _store . database ) ;
74+ const requestExecutor = this . _store . getRequestExecutor ( this . _store . getEffectiveDatabase ( database ) ) ;
7575
7676 const command = new CreateSubscriptionCommand ( this . _store . conventions , options ) ;
7777 await requestExecutor . execute ( command ) ;
@@ -291,7 +291,7 @@ export class DocumentSubscriptions implements IDisposable {
291291 * It downloads a list of all existing subscriptions in a database.
292292 */
293293 public async getSubscriptions ( start : number , take : number , database ?: string ) : Promise < SubscriptionState [ ] > {
294- const requestExecutor = this . _store . getRequestExecutor ( database || this . _store . database ) ;
294+ const requestExecutor = this . _store . getRequestExecutor ( this . _store . getEffectiveDatabase ( database ) ) ;
295295
296296 const command = new GetSubscriptionsCommand ( start , take ) ;
297297 await requestExecutor . execute ( command ) ;
@@ -313,7 +313,7 @@ export class DocumentSubscriptions implements IDisposable {
313313 * Delete a subscription.
314314 */
315315 public async delete ( name : string , database ?: string ) : Promise < void > {
316- const requestExecutor = this . _store . getRequestExecutor ( database || this . _store . database ) ;
316+ const requestExecutor = this . _store . getRequestExecutor ( this . _store . getEffectiveDatabase ( database ) ) ;
317317
318318 const command = new DeleteSubscriptionCommand ( name ) ;
319319 return requestExecutor . execute ( command ) ;
@@ -337,7 +337,7 @@ export class DocumentSubscriptions implements IDisposable {
337337 throwError ( "InvalidArgumentException" , "SubscriptionName cannot be null" ) ;
338338 }
339339
340- const requestExecutor = this . _store . getRequestExecutor ( database || this . _store . database ) ;
340+ const requestExecutor = this . _store . getRequestExecutor ( this . _store . getEffectiveDatabase ( database ) ) ;
341341
342342 const command = new GetSubscriptionStateCommand ( subscriptionName ) ;
343343 await requestExecutor . execute ( command ) ;
@@ -366,7 +366,7 @@ export class DocumentSubscriptions implements IDisposable {
366366 * Force server to close current client subscription connection to the server
367367 */
368368 public async dropConnection ( name : string , database ?: string ) : Promise < void > {
369- const requestExecutor = this . _store . getRequestExecutor ( database || this . _store . database ) ;
369+ const requestExecutor = this . _store . getRequestExecutor ( this . _store . getEffectiveDatabase ( database ) ) ;
370370
371371 const command = new DropSubscriptionConnectionCommand ( name ) ;
372372 return requestExecutor . execute ( command ) ;
@@ -376,15 +376,15 @@ export class DocumentSubscriptions implements IDisposable {
376376 public async enable ( name : string , database : string )
377377 public async enable ( name : string , database ?: string ) {
378378 const operation = new ToggleOngoingTaskStateOperation ( name , "Subscription" , false ) ;
379- await this . _store . maintenance . forDatabase ( database || this . _store . database )
379+ await this . _store . maintenance . forDatabase ( this . _store . getEffectiveDatabase ( database ) )
380380 . send ( operation ) ;
381381 }
382382
383383 public async disable ( name : string )
384384 public async disable ( name : string , database : string )
385385 public async disable ( name : string , database ?: string ) {
386386 const operation = new ToggleOngoingTaskStateOperation ( name , "Subscription" , true ) ;
387- await this . _store . maintenance . forDatabase ( database || this . _store . database )
387+ await this . _store . maintenance . forDatabase ( this . _store . getEffectiveDatabase ( database ) )
388388 . send ( operation ) ;
389389 }
390390}
0 commit comments