Reputation: 4797
There are quite a few tips on the WWW how to delete all documents in a RavenDB database. Some are more complicated than others, i.e. http://vpetroff.blogspot.co.uk/2012/04/deleting-all-documents-in-ravendb.html.
Upvotes: 2
Views: 1727
Reputation: 8373
I've been using version 3, and "Auto/AllDocs"
doesn't seem to work. However, you can retrieve the index names and delete that way, for example:
var indexDefinitions = _documentStore.DatabaseCommands.GetIndexes(0, 100);
foreach (var indexDefinition in indexDefinitions)
{
_documentStore.DatabaseCommands.DeleteByIndex(indexDefinition.Name, new IndexQuery());
}
Upvotes: 2
Reputation: 4797
With the latest edition of RavenDB you can simply use the built in Auto/AllDocs index.
private static void DeleteFiles(IDocumentStore documentStore)
{
var staleIndexesWaitAction = new Action(
delegate
{
while (documentStore.DatabaseCommands.GetStatistics().StaleIndexes.Length != 0)
{
Thread.Sleep(10);
}
});
staleIndexesWaitAction.Invoke();
documentStore.DatabaseCommands.DeleteByIndex("Auto/AllDocs", new IndexQuery());
staleIndexesWaitAction.Invoke();
}
Upvotes: 1