aboutsummaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2022-07-26 01:08:03 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2022-07-26 01:08:03 +0200
commitb03cf48eb2074ef41ced9d59712b005a127c17bf (patch)
tree8932a34952e372dad70f9cd4c6f6742e9f99c4fb /db
parent40407573e35ff9b617faf84ac715de3d791282e4 (diff)
downloadmdir-b03cf48eb2074ef41ced9d59712b005a127c17bf.tar.gz
mdir-b03cf48eb2074ef41ced9d59712b005a127c17bf.tar.bz2
mdir-b03cf48eb2074ef41ced9d59712b005a127c17bf.zip
feat: Add necessary param for packing
Datadir parameter will make easier for later to create the apk.
Diffstat (limited to 'db')
-rw-r--r--db/db.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/db/db.go b/db/db.go
index 948f154..4728aa7 100644
--- a/db/db.go
+++ b/db/db.go
@@ -1,6 +1,8 @@
package db
import (
+ "path"
+
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
@@ -10,8 +12,10 @@ var (
err error
)
-func ConnectDb() {
- DB, err = gorm.Open(sqlite.Open("main.db"), &gorm.Config{})
+func ConnectDb(folder string) {
+ dbPath := path.Join(folder, "main.db")
+
+ DB, err = gorm.Open(sqlite.Open(dbPath), &gorm.Config{})
if err != nil {
panic("failed to connect to the database.")