summaryrefslogtreecommitdiffstats
path: root/src/Eva.cs
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2023-01-16 00:13:54 +0100
committerivarlovlie <git@ivarlovlie.no>2023-01-16 00:13:54 +0100
commit494fc9d7d1f08e05e1ee196bd0746900343b51dd (patch)
tree07fbca21dcf27084d4ac01b0d7098fa61df57e65 /src/Eva.cs
parentdbb09c75202f9d8a91e4babd599807462ecead9f (diff)
downloadblob-bin-494fc9d7d1f08e05e1ee196bd0746900343b51dd.tar.xz
blob-bin-494fc9d7d1f08e05e1ee196bd0746900343b51dd.zip
feat: Fully implemented text/file api, almost finished autodelete service
Diffstat (limited to 'src/Eva.cs')
-rw-r--r--src/Eva.cs52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/Eva.cs b/src/Eva.cs
new file mode 100644
index 0000000..760231e
--- /dev/null
+++ b/src/Eva.cs
@@ -0,0 +1,52 @@
+using Microsoft.EntityFrameworkCore;
+
+namespace BlobBin;
+
+public sealed class Eva : DbContext
+{
+ private readonly bool migrated;
+
+ public Eva(DbContextOptions<Eva> options) : base(options) {
+ if (!migrated) {
+ Database.Migrate();
+ migrated = true;
+ }
+ }
+
+ public DbSet<File> Files { get; set; }
+ public DbSet<Paste> Pastes { get; set; }
+
+ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
+ optionsBuilder.UseSqlite("data source = AppData/main.db");
+ base.OnConfiguring(optionsBuilder);
+ }
+}
+
+public class UploadEntityBase
+{
+ public UploadEntityBase() {
+ Id = Guid.NewGuid();
+ CreatedAt = DateTime.UtcNow;
+ }
+
+ public Guid Id { get; set; }
+ public string PublicId { get; set; }
+ public DateTime CreatedAt { get; set; }
+ public string CreatedBy { get; set; }
+ public DateTime? DeletedAt { get; set; }
+ public string? PasswordHash { get; set; }
+ public bool Singleton { get; set; }
+ public string? AutoDeleteAfter { get; set; }
+ public string? MimeType { get; set; }
+ public string DeletionKey { get; set; }
+ public string? Name { get; set; }
+ public long Length { get; set; }
+}
+
+public class Paste : UploadEntityBase
+{
+ public string? Content { get; set; }
+}
+
+public class File : UploadEntityBase
+{ } \ No newline at end of file