refactor: Update SQL queries to explicitly list columns and fix import paths
This commit is contained in:
parent
29ec555090
commit
7cbe2a07d3
4 changed files with 14 additions and 13 deletions
|
@ -4,7 +4,7 @@ import (
|
|||
"github.com/labstack/echo/v4"
|
||||
"go.uber.org/zap"
|
||||
|
||||
db "github.com/your-username/your-repo/database/sqlite/generated"
|
||||
db "github.com/your-username/your-repo/database/sqlite/generated/sqlite"
|
||||
)
|
||||
|
||||
// API holds all API handlers
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"github.com/labstack/echo/v4"
|
||||
"go.uber.org/zap"
|
||||
|
||||
db "github.com/your-username/your-repo/database/sqlite/generated"
|
||||
db "github.com/your-username/your-repo/database/sqlite/generated/sqlite"
|
||||
)
|
||||
|
||||
type StorageHandler struct {
|
||||
|
|
|
@ -1,28 +1,29 @@
|
|||
-- name: GetAllUsers :many
|
||||
SELECT * FROM users;
|
||||
SELECT id, username FROM users;
|
||||
|
||||
-- name: GetUserByID :one
|
||||
SELECT * FROM users WHERE ID = ?;
|
||||
SELECT id, username FROM users WHERE ID = ?;
|
||||
|
||||
-- name: AddUser :exec
|
||||
INSERT INTO users (Username) VALUES (?);
|
||||
|
||||
-- name: GetUserSessions :many
|
||||
SELECT * FROM user_sessions_view WHERE user_ID = ?;
|
||||
SELECT user_id, username, session_token, created_at, valid_until FROM user_sessions_view WHERE user_ID = ?;
|
||||
|
||||
-- name: AddUserSession :exec
|
||||
INSERT INTO user_sessions (user_ID, session_token, created_at, valid_until, name)
|
||||
VALUES (?, ?, ?, ?, ?);
|
||||
|
||||
-- name: GetObjectsInStorage :many
|
||||
SELECT * FROM object_storage WHERE storage_location = ?;
|
||||
SELECT object_id, object_name, storage_location FROM object_storage WHERE storage_location = ?;
|
||||
|
||||
-- name: GetUserEvents :many
|
||||
SELECT * FROM event_details WHERE organizer = ?;
|
||||
SELECT event_id, event_name, description, location, start_date, end_date, organizer FROM event_details WHERE organizer = ?;
|
||||
|
||||
-- name: GetEventObjects :many
|
||||
SELECT objects.* FROM objects
|
||||
JOIN events_objects ON objects.ID = events_objects.object_ID
|
||||
SELECT objects.id, objects.storagespace_id, objects.name, objects.description, objects.serialnumber, objects.created
|
||||
FROM objects
|
||||
JOIN events_objects ON objects.ID = events_objects.object_ID
|
||||
WHERE events_objects.event_ID = ?;
|
||||
|
||||
-- name: AddObject :exec
|
||||
|
@ -34,21 +35,21 @@ INSERT INTO events (user_ID, Name, Description, Location, Start_Date, End_Date)
|
|||
VALUES (?, ?, ?, ?, ?, ?);
|
||||
|
||||
-- name: GetEventCheckIns :many
|
||||
SELECT * FROM check_in_log WHERE event_name = ?;
|
||||
SELECT check_in_id, username, event_name, object_name, datetime, checkin_state FROM check_in_log WHERE event_name = ?;
|
||||
|
||||
-- name: AddCheckIn :exec
|
||||
INSERT INTO check_in (user_ID, checkin_event_ID, event_ID, object_ID, checkin_state_ID, datetime)
|
||||
VALUES (?, ?, ?, ?, ?, ?);
|
||||
|
||||
-- name: GetObjectAnnotations :many
|
||||
SELECT * FROM annotations WHERE object_ID = ?;
|
||||
SELECT id, user_id, object_id, event_id, check_in_id, events_object_id, text, datetime FROM annotations WHERE object_ID = ?;
|
||||
|
||||
-- name: AddAnnotation :exec
|
||||
INSERT INTO annotations (user_ID, object_ID, event_ID, check_in_ID, events_object_ID, text, datetime)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?);
|
||||
|
||||
-- name: GetEventPictures :many
|
||||
SELECT * FROM pictures WHERE event_ID = ?;
|
||||
SELECT id, user_id, storagespace_id, object_id, event_id, check_in_id, path, description, datetime FROM pictures WHERE event_ID = ?;
|
||||
|
||||
-- name: AddPicture :exec
|
||||
INSERT INTO pictures (user_ID, storagespace_ID, object_ID, event_ID, check_in_ID, Path, Description, datetime)
|
||||
|
|
2
main.go
2
main.go
|
@ -23,7 +23,7 @@ import (
|
|||
"gopkg.in/yaml.v2"
|
||||
|
||||
"github.com/your-username/your-repo/api"
|
||||
db "github.com/your-username/your-repo/database/sqlite/generated"
|
||||
db "github.com/your-username/your-repo/database/sqlite/generated/sqlite"
|
||||
)
|
||||
|
||||
//go:embed static/*
|
||||
|
|
Loading…
Add table
Reference in a new issue