Intro implementation of Groups SQL repository interface

Signed-off-by: Ethan Wellenreiter <ewellenreiter@gmail.com>
This commit is contained in:
Ethan Wellenreiter 2025-05-06 18:08:51 -04:00
parent 6bc2b58cdb
commit 7456c40459
2 changed files with 38 additions and 0 deletions

View File

@ -52,6 +52,7 @@ Table images {
receiptid integer
created_at timestamp
path varchar
added bool
}

View File

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