Files
zap-stream-api/NostrStreamer/Database/Configuration/UserStreamGuestConfiguration.cs
2023-07-25 17:45:44 +01:00

27 lines
790 B
C#

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace NostrStreamer.Database.Configuration;
public class UserStreamGuestConfiguration : IEntityTypeConfiguration<UserStreamGuest>
{
public void Configure(EntityTypeBuilder<UserStreamGuest> builder)
{
builder.HasKey(a => a.Id);
builder.Property(a => a.PubKey)
.IsRequired();
builder.Property(a => a.Sig);
builder.Property(a => a.Relay);
builder.Property(a => a.Role);
builder.Property(a => a.ZapSplit);
builder.HasOne(a => a.Stream)
.WithMany(a => a.Guests)
.HasForeignKey(a => a.StreamId);
builder.HasIndex(a => new {a.StreamId, a.PubKey})
.IsUnique();
}
}