StreamStore.Sql.PostgreSql
0.2.0
See the version list below for details.
dotnet add package StreamStore.Sql.PostgreSql --version 0.2.0
NuGet\Install-Package StreamStore.Sql.PostgreSql -Version 0.2.0
<PackageReference Include="StreamStore.Sql.PostgreSql" Version="0.2.0" />
paket add StreamStore.Sql.PostgreSql --version 0.2.0
#r "nuget: StreamStore.Sql.PostgreSql, 0.2.0"
// Install StreamStore.Sql.PostgreSql as a Cake Addin #addin nuget:?package=StreamStore.Sql.PostgreSql&version=0.2.0 // Install StreamStore.Sql.PostgreSql as a Cake Tool #tool nuget:?package=StreamStore.Sql.PostgreSql&version=0.2.0
StreamStore.Sql.PostgreSql
PostgreSQL backend database for StreamStore asynchronous event sourcing library.
Installation
To install the package, you can use the following command from the command line:
dotnet add package StreamStore
dotnet add package StreamStore.Sql.PostgreSql
or from Nuget Package Manager Console:
Install-Package StreamStore
Install-Package StreamStore.Sql.PostgreSql
Usage
Storage
By default the library provisioning tables automatically, however you must create database or provide connection string to existing database.
If you want to create table manually, you can use the following script:
CREATE TABLE IF NOT EXISTS public.Events (
Id text NOT NULL,
StreamId text NOT NULL,
Timestamp timestamp NOT NULL,
Revision integer NOT NULL,
Data bytea NOT NULL,
PRIMARY KEY (Id, StreamId)
);
CREATE INDEX IF NOT EXISTS ix_events_stream_id ON Events(StreamId);
CREATE INDEX IF NOT EXISTS ix_events_stream_revision ON Events(Revision);
CREATE UNIQUE INDEX IF NOT EXISTS ix_events_stream_id_revision ON Events(StreamId, Revision);
Configuration
You can define configuration of the library in appsettings.json
file:
{
"ConnectionStrings": {
"StreamStore": "Host=localhost;Port=5432;Database=streamstore;Username=streamstore;Password=streamstore" // Required for single tenant configuration
},
"StreamStore": { // Optional
"PostgreSql": {
"SchemaName": "public", // Optional
"TableName": "Events", // Optional
"ProvisionSchema": true, // Optional
}
}
}
Register in DI container
services.ConfigureStreamStore(x =>...
// Register single database implementation
x.WithSingleDatabase(c => ...
c.UsePostgresDatabase(x =>
c => c.ConfigureDatabase(x => // Configure database options.
x.WithConnectionString("your-connection-string") // Required. Connection string.
x.WithSchema("your-schema-name"); // Optional. Schema name, default is "public".
x.WithTableName("your-table-name"); // Optional. Table name, default is "Events".
)
)
// Or enable multitenancy
x.WithMultitenancy(c => ...
c.UsePostgresDatabase(x =>
x.WithConnectionStringProvider<Provider>() // Required. Register your
// ISqlTenantConnectionStringProvider implementation.
c => c.ConfigureDatabase(x =>...) // Optional. Configure database options will be used as
// template for tenant database configuration, optional.
)
)
);
Use in application code
How to use StreamStore in your application code you can find on StreamStore page.
Example
You can find an example of usage in the StreamStore.Sql.Example project.
Testing
In order to run tests placed in StreamStore.Sql.Tests/PostgreSql, you need to have a running PostgreSQL instance. You can use docker-compose docker-compose.yaml to run it.
License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Dapper (>= 2.1.35)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Npgsql (>= 8.0.5)
- StreamStore.Sql (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.