feat: working docker image and compose file

This commit is contained in:
2025-02-24 19:44:19 +00:00
parent 18ecfecd54
commit c9cd0df9ca
7 changed files with 68 additions and 7 deletions

View File

@@ -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

View File

@@ -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)