see on GitHub

Operations : Server : How to Create a Database

Create a new database on a server.

Syntax

public CreateDatabaseOperation(
    DatabaseRecord databaseRecord,
    int replicationFactor = 1)
{
}

Parameters Type Description
databaseRecord DatabaseRecord instance of DatabaseRecord containing database configuration
replicationFactor int indicates how many nodes should contain the database

DatabaseRecrod

DatabaseRecord is a collection of database configurations.

Constructor

Name Description
DatabaseRecord(string databaseName) Initialize a new database record.

Properties

Name Type Description
Disabled bool (default: false) Disable the database.
Encrypted bool (default: false) Enables database encryption.
DeletionInProgess Dictionary<string, DeletionInProgess> Mark the deletion of the database from specific nodes.
Topology DatabaseTopology By default it is null and the server will decided on which nodes to place the database according to the Replication Factor.
ConflictSolverConfig ConflictSolver Specify the strategy to resolve Conflicts.
Indexes Dictionary<string, IndexDefinition> Define Indexes
AutoIndexes Dictionary<string, AutoIndexDefinition> Define Auto Indexes
Settings Dictionary<string, string> Provide Configuration settings.
Revisions RevisionsConfiguration Set Revision configuration.
Expiration ExpirationConfiguration Set Expiration configuration.
RavenConnectionStrings Dictionary<string, RavenConnectionString> Add Raven Connection String
SqlConnectionStrings Dictionary<string, SqlConnectionString> Add SQL Connection String
PeriodicBackups List<PeriodicBackupConfiguration> Add Backup tasks.
ExternalReplications List<ExternalReplications> Add External Replication tasks.
RavenEtls List<RavenEtlConfiguration> Add Raven ETL tasks.
SqlEtls List<SqlEtlConfiguration> Add SQL ETL tasks.
Client ClientConfiguration Set Client Configuration

Remarks

If Topology is specified, the replicationFactor will be ignored.

Example

store.Maintenance.Server.Send(new CreateDatabaseOperation(new DatabaseRecord("MyNewDatabase")));
await store.Maintenance.Server.SendAsync(new CreateDatabaseOperation(new DatabaseRecord("MyNewDatabase")));