Init
This commit is contained in:
@ -0,0 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace NostrStreamer.Database.Configuration;
|
||||
|
||||
public class PaymentsConfiguration : IEntityTypeConfiguration<Payment>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Payment> builder)
|
||||
{
|
||||
builder.HasKey(a => a.PubKey);
|
||||
builder.Property(a => a.Invoice)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(a => a.IsPaid)
|
||||
.IsRequired();
|
||||
}
|
||||
}
|
18
NostrStreamer/Database/Configuration/UserConfiguration.cs
Normal file
18
NostrStreamer/Database/Configuration/UserConfiguration.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace NostrStreamer.Database.Configuration;
|
||||
|
||||
public class UserConfiguration : IEntityTypeConfiguration<User>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<User> builder)
|
||||
{
|
||||
builder.HasKey(a => a.PubKey);
|
||||
builder.Property(a => a.StreamKey)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(a => a.Event);
|
||||
builder.Property(a => a.Balance)
|
||||
.IsRequired();
|
||||
}
|
||||
}
|
10
NostrStreamer/Database/Payment.cs
Normal file
10
NostrStreamer/Database/Payment.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace NostrStreamer.Database;
|
||||
|
||||
public class Payment
|
||||
{
|
||||
public string PubKey { get; init; } = null!;
|
||||
|
||||
public string Invoice { get; init; } = null!;
|
||||
|
||||
public bool IsPaid { get; init; }
|
||||
}
|
26
NostrStreamer/Database/StreamerContext.cs
Normal file
26
NostrStreamer/Database/StreamerContext.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NostrStreamer.Database;
|
||||
|
||||
public class StreamerContext : DbContext
|
||||
{
|
||||
public StreamerContext()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public StreamerContext(DbContextOptions<StreamerContext> ctx) : base(ctx)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(typeof(StreamerContext).Assembly);
|
||||
}
|
||||
|
||||
public DbSet<User> Users => Set<User>();
|
||||
|
||||
public DbSet<Payment> Payments => Set<Payment>();
|
||||
}
|
41
NostrStreamer/Database/User.cs
Normal file
41
NostrStreamer/Database/User.cs
Normal file
@ -0,0 +1,41 @@
|
||||
namespace NostrStreamer.Database;
|
||||
|
||||
public class User
|
||||
{
|
||||
public string PubKey { get; init; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Stream key
|
||||
/// </summary>
|
||||
public string StreamKey { get; init; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Most recent nostr event published
|
||||
/// </summary>
|
||||
public string? Event { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Sats balance
|
||||
/// </summary>
|
||||
public long Balance { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Stream title
|
||||
/// </summary>
|
||||
public string? Title { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Stream summary
|
||||
/// </summary>
|
||||
public string? Summary { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Stream cover image
|
||||
/// </summary>
|
||||
public string? Image { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Comma seperated tags
|
||||
/// </summary>
|
||||
public string? Tags { get; init; }
|
||||
}
|
Reference in New Issue
Block a user