var store = new DocumentStore { Database = myDatabaseName, Urls = new[] {"http://localhost:8080"} }.Initialize() as DocumentStore;
var operation = new GetDatabaseNamesOperation(0, 1000); // 1000 is safe enough for me. var databaseNames = store.Maintenance.Server.Send(operation);
if (databaseNames.Any(_ => _ == store.Database)) return store; // database already exists!
var createDatabaseOperation = new CreateDatabaseOperation(new DatabaseRecord(store.Database)); store.Maintenance.Server.Send(createDatabaseOperation);
Hibernating Rhinos Ltd
Oren Eini l CEO l Mobile: + 972-52-548-6969
Office: +972-4-622-7811 l Fax: +972-153-4-622-7811
--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
public bool DatabaseExists(string databaseName) => SafelyExecuteDatabaseCommandsOperation(() => { var key = "Raven/Databases/" + databaseName; return _store.DatabaseCommands.ForSystemDatabase().Head(key) != null;});
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.