Intro implementation of Groups SQL repository interface
Signed-off-by: Ethan Wellenreiter <ewellenreiter@gmail.com>
This commit is contained in:
parent
6bc2b58cdb
commit
7456c40459
@ -52,6 +52,7 @@ Table images {
|
||||
receiptid integer
|
||||
created_at timestamp
|
||||
path varchar
|
||||
added bool
|
||||
}
|
||||
|
||||
|
||||
|
||||
37
backend/internal/storage/sql-groups.go
Normal file
37
backend/internal/storage/sql-groups.go
Normal 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
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user