Lyo.Comment.Postgres
1.0.6
See the version list below for details.
dotnet add package Lyo.Comment.Postgres --version 1.0.6
NuGet\Install-Package Lyo.Comment.Postgres -Version 1.0.6
<PackageReference Include="Lyo.Comment.Postgres" Version="1.0.6" />
<PackageVersion Include="Lyo.Comment.Postgres" Version="1.0.6" />
<PackageReference Include="Lyo.Comment.Postgres" />
paket add Lyo.Comment.Postgres --version 1.0.6
#r "nuget: Lyo.Comment.Postgres, 1.0.6"
#:package Lyo.Comment.Postgres@1.0.6
#addin nuget:?package=Lyo.Comment.Postgres&version=1.0.6
#tool nuget:?package=Lyo.Comment.Postgres&version=1.0.6
Lyo.Comment.Postgres
PostgreSQL implementation of Lyo.Comment using Entity Framework Core. Persists comments to the comment.comment table and reactions to comment.comment_reaction (PostgresCommentOptions.Schema = "comment") and ships migrations. Comments have subject / actor (for_entity_* / from_entity_*), optional ReplyToCommentId (parent comment), and cached LikeCount / DislikeCount counters.
PostgresCommentStore implements ICommentStore and Lyo.Health.IHealth (HealthCheckName = "comment-postgres"). Registering the store also registers a liveness probe.
Features
- Subject/actor. Same relation endpoint shape as Rating and Note.
- Reply threads.
ReplyToCommentIdpoints to the parent comment;GetRepliesAsync(parentId)returns direct replies;DeleteAsync(id, deleteReplies: true)walks the descendant tree and soft-deletes every nested reply (plus their reactions). - Reactions (like/dislike). Tracked per user via the
comment_reactiontable; exactly one reaction per user per comment. FlippingLike↔Dislikemutates the existing row and adjusts the cached counters on the parent comment. - IsEdited. Automatically set to
truebySaveAsyncwhenever an existing row is updated.
Examples
Usage
services.AddPostgresCommentStore(new PostgresCommentOptions {
ConnectionString = "...",
EnableAutoMigrations = true
});
Usage (2)
{
"PostgresComment": {
"ConnectionString": "Host=localhost;Database=comment;...",
"EnableAutoMigrations": true
}
}
Usage (3)
services.AddPostgresCommentStoreFromConfiguration(configuration);
Example
await commentStore.SaveAsync(new CommentRecord {
SubjectEntityType = "Docket",
SubjectEntityId = docketId.ToString(),
ActorEntityType = "User",
ActorEntityId = userId.ToString(),
Content = "Great work on this case!"
});
await commentStore.SaveAsync(new CommentRecord {
SubjectEntityType = "Docket",
SubjectEntityId = docketId.ToString(),
ActorEntityType = "User",
ActorEntityId = otherUserId.ToString(),
Content = "I agree!",
ReplyToCommentId = parentCommentId
});
var commentRef = CommentRef.ForComment(commentId);
var userRef = EntityRef.ForGuid("User", userId);
await commentStore.AddReactionAsync(commentRef, userRef, CommentReactionType.Like);
var reaction = await commentStore.GetReactionAsync(commentRef, userRef);
await commentStore.RemoveReactionAsync(commentRef, userRef);
Migrations
export COMMENT_CONNECTION_STRING="Host=localhost;Database=comment;Username=postgres;Password=postgres"
dotnet ef migrations add MigrationName --project Features/Comment/Lyo.Comment.Postgres
DI extensions
AddCommentDbContextFactory(Action<PostgresCommentOptions>)/AddCommentDbContextFactory(PostgresCommentOptions)register only theIDbContextFactory<CommentDbContext>.AddCommentDbContextFactoryFromConfiguration(IConfiguration, string sectionName = PostgresCommentOptions.SectionName)same, bound from configuration (default section:PostgresComment).AddPostgresCommentStore(Action<PostgresCommentOptions>)/AddPostgresCommentStore(PostgresCommentOptions)register the DbContext factory and theICommentStoresingleton.AddPostgresCommentStoreFromConfiguration(IConfiguration, string sectionName = PostgresCommentOptions.SectionName)register the store using configuration binding.
Usage
Or with configuration:
Schema
- comment.comment.
EntityRelationEntityBase:id(uuid), subject/actor columns (for_entity_type,for_entity_id,from_entity_type,from_entity_id, nullable varchar 128/256),tenant_id,context,visibility,created_at,expires_at,deleted_at,deleted_by_type,deleted_by_id,metadata(jsonb), plus comment-specificcontent,reply_to_comment_id(nullable uuid),like_count,dislike_count,is_edited, andupdated_timestamp. - comment.comment_reaction.
id(uuid); subjectfor_entity_*(always"Comment"+ parent id); actorfrom_entity_*;tenant_id(nullable uuid, inherited from the parent comment at write time),reaction_type(int;0 = Like,1 = Dislike),created_timestamp.
Tenancy
PostgresCommentStore accepts an optional Guid? tenantId on every
read/write method (mirroring IFavoriteStore) and resolves it through
TenancyResolver under the policy configured in
PostgresCommentOptions.Tenancy (inheriting from EntityRefOptions.Mode when
unset). The comment tenant_id column is non-null, so only
SingleTenantDefault and MultiTenantStrict modes are valid. SystemOnly is
rejected at store construction. The store applies a WhereTenant filter on
every query, and reactions inherit the parent comment's TenantId on insert
so the sub-table stays consistent with the parent. See
Lyo.EntityReference.Postgres
for the policy matrix and appsettings.json snippet.
{
"PostgresComment": {
"ConnectionString": "Host=localhost;Database=lyo;...",
"Tenancy": { "Mode": "MultiTenantStrict" }
}
}
Dependencies
Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).
Lyo.Comment(direct, lyo)Lyo.EntityReference.Models(direct, lyo)Lyo.EntityReference.Postgres(direct, lyo)Lyo.Exceptions(direct, lyo)Lyo.Health(direct, lyo)Lyo.Postgres(direct, lyo)Microsoft.EntityFrameworkCore10.0.5(direct, microsoft)Microsoft.EntityFrameworkCore.Design10.0.5(direct, microsoft)Microsoft.Extensions.Configuration.Binder10.0.5(direct, microsoft)Lyo.Common(transitive, lyo)Microsoft.EntityFrameworkCore.Relational10.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)Microsoft.Extensions.Options.ConfigurationExtensions10.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.Comment (>= 1.0.6)
- Lyo.EntityReference.Models (>= 1.0.6)
- Lyo.EntityReference.Postgres (>= 1.0.6)
- Lyo.Exceptions (>= 1.0.6)
- Lyo.Health (>= 1.0.6)
- Lyo.Postgres (>= 1.0.6)
- Microsoft.EntityFrameworkCore (>= 10.0.5)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.