Lyo.ShortUrl.Postgres
2.0.0
See the version list below for details.
dotnet add package Lyo.ShortUrl.Postgres --version 2.0.0
NuGet\Install-Package Lyo.ShortUrl.Postgres -Version 2.0.0
<PackageReference Include="Lyo.ShortUrl.Postgres" Version="2.0.0" />
<PackageVersion Include="Lyo.ShortUrl.Postgres" Version="2.0.0" />
<PackageReference Include="Lyo.ShortUrl.Postgres" />
paket add Lyo.ShortUrl.Postgres --version 2.0.0
#r "nuget: Lyo.ShortUrl.Postgres, 2.0.0"
#:package Lyo.ShortUrl.Postgres@2.0.0
#addin nuget:?package=Lyo.ShortUrl.Postgres&version=2.0.0
#tool nuget:?package=Lyo.ShortUrl.Postgres&version=2.0.0
Lyo.ShortUrl.Postgres
EF Core schema and DbContext registration for a PostgreSQL-backed short-URL store.
This package has no
PostgresShortUrlService/PostgresShortUrlStore. It ships the database pieces (DbContext, entities, migrations, options, and DI helpers for the context). To get anIShortUrlServicethat talks to this schema, implement one onShortUrlDbContext(or useLyo.ShortUrl.ShortUrlServicefor id-only generation. That class does not persist anything).
Examples
Service registration (Extensions)
services.AddShortUrlDbContextFactoryFromConfiguration(configuration);
services.AddSingleton<IShortUrlService, MyEfBackedShortUrlService>();
// where MyEfBackedShortUrlService takes IDbContextFactory<ShortUrlDbContext>
// and IShortUrlGenerator (services.AddShortUrlGenerator()).
Package contents
ShortUrlDbContext+ShortUrlDbContextFactoryunderDatabase/, withDbSet<ShortUrlEntity>andDbSet<UrlClickEntity>. The default schema is"url".ShortUrlEntity. The canonical short-link row: string-keyedId(max 100 chars) used as the short code,LongUrl(≤ 1024), optionalCustomAlias,CreatedTimestamp/UpdatedTimestamp/ExpirationDate/LastAccessedDate,ClickCount,IsActive, and aClicksnavigation. Includes aFromShortenRequest(...)factory and aBuildShortUrl(baseUrl)helper that mirrorsLyo.ShortUrl.ShortUrlService'sBaseUrlbehaviour.UrlClickEntity. Append-only click log row (ShortUrlIdFK,ClickedAt, optionalIpAddress/UserAgent/Referrer).*EntityConfigurationFluent API mappings under the same folder.PostgresShortUrlOptions(SectionName = "PostgresShortUrl",Schema = "url",ConnectionString,EnableAutoMigrations).Constants.Metricsnames (urlshortener.postgres.statistics.duration,.delete.duration,.update.duration), reserved for downstream service implementations.InitialCreatemigration underMigrations/.
Service registration (Extensions)
| Entry point | Effect |
|---|---|
AddShortUrlDbContext(string connectionString) |
Registers the DbContext factory plus a scoped ShortUrlDbContext resolved from the factory. |
AddShortUrlDbContextFactory(Action<PostgresShortUrlOptions>) (plus (options) and FromConfiguration overloads) |
Registers IOptions<PostgresShortUrlOptions>, AddPostgresMigrations<ShortUrlDbContext, PostgresShortUrlOptions>(), and IDbContextFactory<ShortUrlDbContext> (UseNpgsql + migrations history under the url schema). |
There is intentionally no AddPostgresShortUrlStore / AddPostgresShortUrlService. See the note at the top of this README. Wire your own service on top of the factory, for example:
Database schema
| Table | Notable columns |
|---|---|
url.short_urls |
Id (PK, string ≤ 100), LongUrl (≤ 1024), CustomAlias? (≤ 100), CreatedTimestamp, UpdatedTimestamp?, ExpirationDate?, LastAccessedDate?, ClickCount, IsActive. |
url.url_clicks |
Id (PK, long), ShortUrlId (FK → short_urls.Id), ClickedAt, optional IpAddress (≤ 45), UserAgent (≤ 500), Referrer (≤ 512). |
(Exact table / column names follow the EF defaults plus the configurations under Database/. The migrations history is tracked in __EFMigrationsHistory under the same url schema.)
Dependencies
Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).
Lyo.Configuration(direct, lyo)Lyo.Exceptions(direct, lyo)Lyo.Postgres(direct, lyo)Lyo.ShortUrl(direct, lyo)Lyo.Common.Core(transitive, lyo)Lyo.Health(transitive, lyo)Lyo.Metrics(transitive, lyo)Lyo.Result(transitive, lyo)Microsoft.Bcl.AsyncInterfaces10.0.5(transitive, microsoft, netstandard2.0)Microsoft.EntityFrameworkCore10.0.5(transitive, microsoft)Microsoft.EntityFrameworkCore.Design10.0.5(transitive, microsoft)Microsoft.EntityFrameworkCore.Relational10.0.5(transitive, microsoft)Microsoft.Extensions.Configuration.Binder10.0.5(transitive, microsoft)Microsoft.Extensions.DependencyInjection.Abstractions10.0.5(transitive, microsoft)Microsoft.Extensions.Hosting.Abstractions10.0.5(transitive, microsoft)Microsoft.Extensions.Logging.Abstractions10.0.5(transitive, microsoft)Microsoft.Extensions.Options10.0.5(transitive, microsoft)Npgsql.EntityFrameworkCore.PostgreSQL10.0.3(transitive, third-party)System.Memory4.6.3(transitive, microsoft, netstandard2.0)System.Text.Json10.0.5(transitive, microsoft, netstandard2.0)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Lyo.Configuration (>= 2.0.0)
- Lyo.Exceptions (>= 2.0.0)
- Lyo.Postgres (>= 2.0.0)
- Lyo.ShortUrl (>= 2.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Lyo.ShortUrl.Postgres:
| Package | Downloads |
|---|---|
|
Lyo.Leaderboard.Api
HTTP API for Lyo.Leaderboard. Embed via AddLeaderboardApi / MapLeaderboardApiEndpoints. |
|
|
Lyo.ShortUrl.Seed
EF seed of short URLs and one click each. |
GitHub repositories
This package is not used by any popular GitHub repositories.