From 7456c40459cfaae404d59d57a99c0b8e48dfe3af Mon Sep 17 00:00:00 2001 From: Ethan Wellenreiter Date: Tue, 6 May 2025 18:08:51 -0400 Subject: [PATCH] Intro implementation of Groups SQL repository interface Signed-off-by: Ethan Wellenreiter --- backend/internal/db/temp.txt | 1 + backend/internal/storage/sql-groups.go | 37 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 backend/internal/storage/sql-groups.go diff --git a/backend/internal/db/temp.txt b/backend/internal/db/temp.txt index fd8da1d..3616474 100644 --- a/backend/internal/db/temp.txt +++ b/backend/internal/db/temp.txt @@ -52,6 +52,7 @@ Table images { receiptid integer created_at timestamp path varchar + added bool } diff --git a/backend/internal/storage/sql-groups.go b/backend/internal/storage/sql-groups.go new file mode 100644 index 0000000..8e882f5 --- /dev/null +++ b/backend/internal/storage/sql-groups.go @@ -0,0 +1,37 @@ +package storage + +import ( + "context" + "database/sql" +) + +type SQLGroupsStore struct { + db *sql.DB +} + +func (s *SQLGroupsStore) GetByID(ctx context.Context, id int64) (*Group, error) { + query := `SELECT id, name, owner FROM groups WHERE id = $1` + + group := &Group{} + err := s.db.QueryRowContext(ctx, query, id).Scan(&group.ID, &group.Name, &group.Owner) + if err != nil { + return nil, err + } + + return group, nil +} + +func (s *SQLGroupsStore) GetUserGroups(ctx context.Context, userID int64) ([]*Group, error) { + // Implement logic to retrieve user's groups from the database +} +func (s *SQLGroupsStore) GetUsersInGroup(ctx context.Context, groupId int64) ([]*User, error) { + // Implement logic to retrieve users in a group from the database +} + +func (s *SQLGroupsStore) Create(ctx context.Context, group *Group) error { + // Implement logic to create a new group in the database +} + +func (s *SQLGroupsStore) Delete(ctx context.Context, id int64) error { + // Implement logic to delete a group from the database +}