From f13a07aa433298de91e1c4aff68f72be6d851be2 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Mon, 6 Jun 2022 02:49:05 +0200 Subject: Initial commit --- db/db.go | 21 +++++++++++++++++++++ db/model.go | 11 +++++++++++ 2 files changed, 32 insertions(+) create mode 100644 db/db.go create mode 100644 db/model.go (limited to 'db') 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 +} -- cgit v1.2.3