aboutsummaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/db.go21
-rw-r--r--db/model.go11
2 files changed, 32 insertions, 0 deletions
diff --git a/db/db.go b/db/db.go
new file mode 100644
index 0000000..128dcc8
--- /dev/null
+++ b/db/db.go
@@ -0,0 +1,21 @@
+package db
+
+import (
+ "gorm.io/driver/sqlite"
+ "gorm.io/gorm"
+)
+
+var (
+ DB *gorm.DB
+ err error
+)
+
+func ConnectDb() {
+ DB, err = gorm.Open(sqlite.Open("test.db"), &gorm.Config{})
+
+ if err != nil {
+ panic("failed to connect to the database.")
+ }
+
+ DB.AutoMigrate(&YdlEntry{})
+}
diff --git a/db/model.go b/db/model.go
new file mode 100644
index 0000000..3094472
--- /dev/null
+++ b/db/model.go
@@ -0,0 +1,11 @@
+package db
+
+import "gorm.io/gorm"
+
+type YdlEntry struct {
+ gorm.Model
+ Title string
+ Link string
+ Format string
+ Output_folder string
+}