receipt_indexer/backend/internal/storage/sql-groups.go
Ethan Wellenreiter 7456c40459 Intro implementation of Groups SQL repository interface
Signed-off-by: Ethan Wellenreiter <ewellenreiter@gmail.com>
2025-05-06 18:09:37 -04:00

38 lines
1003 B
Go

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
}