Adds subscriptions

This commit is contained in:
Jonathan Bourdon
2024-08-04 03:27:21 -04:00
parent 303619cc18
commit 68ef947e26
12 changed files with 413 additions and 147 deletions

View File

@@ -21,13 +21,23 @@ public class ContentDbContext(
.Property(c => c.CreatedAt)
.ValueGeneratedOnAdd()
.HasDefaultValueSql("CURRENT_TIMESTAMP");
modelBuilder
.Entity<Content>()
.HasOne(c => c.Creator)
.WithMany()
.HasForeignKey(c => c.CreatedBy);
modelBuilder
.Entity<Subscription>()
.HasOne(c => c.Creator)
.WithMany()
.HasForeignKey(c => c.CreatorId);
modelBuilder
.Entity<Subscription>()
.HasKey(s => new { s.CreatedBy, s.CreatorId });
modelBuilder
.Entity<Creator>()
.OwnsOne<About>(x => x.About);

View File

@@ -2,8 +2,8 @@
public class Subscription
{
public Guid Id { get; init; }
public Guid CreatorId { get; init; }
public Guid CreatedBy { get; init; }
public DateTimeOffset CreatedAt { get; init; }
public Guid CreatorId { get; init; }
public Creator? Creator { get; set; }
}