Operations: How to Switch Operations to a Different Database

By default, the operations available directly in store are working on a default database that was setup for that store. To switch operations to a different database that is available on that server use the forDatabase method.

Operations.forDatabase

OperationExecutor forDatabase(String databaseName);
Parameters
databaseName String Name of a database for which you want to get new Operations
Return Value
OperationExecutor New instance of Operations that is scoped to the requested database

Example

OperationExecutor operations = documentStore.operations().forDatabase("otherDatabase");

How to Switch Maintenance Operations to a Different Database

As with operations, by default the maintenance operations available directly in store are working on a default database that was setup for that store. To switch maintenance operations to a different database use the forDatabase method.

Maintenance.forDatabase

MaintenanceOperationExecutor forDatabase(String databaseName);
Parameters
databaseName String Name of a database for which you want to get new maintenance operations
Return Value
MaintenanceOperationExecutor New instance of maintenance that is scoped to the requested database

Example

MaintenanceOperationExecutor maintenanceOperations = documentStore.maintenance().forDatabase("otherDatabase");