feat: working docker image and compose file
This commit is contained in:
@@ -2,16 +2,22 @@ package models
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"os"
|
||||
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
const CONNECTION = "postgresql://localhost:5432/haystack?sslmode=disable"
|
||||
|
||||
var db *sql.DB
|
||||
|
||||
func InitDatabase() error {
|
||||
database, err := sql.Open("postgres", CONNECTION)
|
||||
connection := os.Getenv("DB_CONNECTION")
|
||||
|
||||
if len(connection) == 0 {
|
||||
return errors.New("DB_CONNECTION env was not found.")
|
||||
}
|
||||
|
||||
database, err := sql.Open("postgres", connection)
|
||||
|
||||
db = database
|
||||
|
||||
|
||||
@@ -3,11 +3,13 @@ package models
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
. "github.com/go-jet/jet/v2/postgres"
|
||||
"screenmark/screenmark/.gen/haystack/haystack/model"
|
||||
. "screenmark/screenmark/.gen/haystack/haystack/table"
|
||||
|
||||
. "github.com/go-jet/jet/v2/postgres"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
@@ -22,6 +24,8 @@ func GetImage(imageId string) (model.UserImages, error) {
|
||||
id := uuid.MustParse(imageId)
|
||||
stmt := UserImages.SELECT(UserImages.ImageName, UserImages.Image).WHERE(UserImages.ID.EQ(UUID(id)))
|
||||
|
||||
log.Println(stmt.DebugSql())
|
||||
|
||||
images := []model.UserImages{}
|
||||
err := stmt.Query(db, &images)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user