aboutsummaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2022-06-06 02:49:05 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2022-06-06 02:49:05 +0200
commitf13a07aa433298de91e1c4aff68f72be6d851be2 (patch)
tree5ebb10ed5f91b251ccc16c74a631448b5abb6145 /db
downloadmdir-f13a07aa433298de91e1c4aff68f72be6d851be2.tar.gz
mdir-f13a07aa433298de91e1c4aff68f72be6d851be2.tar.bz2
mdir-f13a07aa433298de91e1c4aff68f72be6d851be2.zip
Initial commit
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
+}