Skip to content

The search box knows all the secrets -- try it!

Polecat is part of the Critter Stack ecosystem.

JasperFx Logo JasperFx provides formal support for Polecat and other Critter Stack libraries. Please check our Support Plans for more details.

Tearing Down Document Storage

Polecat provides methods for cleaning up data, primarily useful during testing and development.

Cleaning All Documents

Delete all data from all document tables:

cs
await store.Advanced.CleanAllDocumentsAsync();

This executes DELETE FROM on every pc_doc_* table.

Cleaning a Specific Type

Delete all documents of a specific type:

cs
await store.Advanced.CleanAsync<User>();

Cleaning All Event Data

Delete all events, streams, and progression data:

cs
await store.Advanced.CleanAllEventDataAsync();

This cleans:

  • pc_events -- All event records
  • pc_streams -- All stream metadata
  • pc_event_progression -- All daemon progression

Usage in Tests

Cleaning is most commonly used in integration test setup:

cs
public class MyTests : IAsyncLifetime
{
    private IDocumentStore _store = null!;

    public async Task InitializeAsync()
    {
        _store = DocumentStore.For(opts => { ... });

        // Clean slate for each test
        await _store.Advanced.CleanAllDocumentsAsync();
        await _store.Advanced.CleanAllEventDataAsync();
    }

    public async Task DisposeAsync()
    {
        await _store.DisposeAsync();
    }
}

WARNING

These methods permanently delete data. They should only be used in development and testing environments, never in production.

Released under the MIT License.