1
|
|
|
package deck |
2
|
|
|
|
3
|
|
|
import ( |
4
|
|
|
"context" |
5
|
|
|
|
6
|
|
|
"github.com/jackc/pgx/v5/pgxpool" |
7
|
|
|
db "github.com/memnix/memnix-rest/db/sqlc" |
8
|
|
|
"github.com/memnix/memnix-rest/domain" |
9
|
|
|
) |
10
|
|
|
|
11
|
|
|
// SQLRepository is the repository for the deck. |
12
|
|
|
type SQLRepository struct { |
13
|
|
|
q *db.Queries // q is the sqlc queries. |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
// Create creates a new deck. |
17
|
|
|
func (r *SQLRepository) Create(_ context.Context, _ *domain.Deck) error { |
18
|
|
|
return nil |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
// Update updates the deck with the given id. |
22
|
|
|
func (r *SQLRepository) Update(_ context.Context, _ *domain.Deck) error { |
23
|
|
|
return nil |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
// Delete deletes the deck with the given id. |
27
|
|
|
func (r *SQLRepository) Delete(_ context.Context, _ uint) error { |
28
|
|
|
return nil |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
// CreateFromUser creates a new deck from the given user. |
32
|
|
|
func (r *SQLRepository) CreateFromUser(_ context.Context, _ domain.User, _ *domain.Deck) error { |
33
|
|
|
return nil |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
// GetByID returns the deck with the given id. |
37
|
|
|
func (r *SQLRepository) GetByID(_ context.Context, _ uint) (domain.Deck, error) { |
38
|
|
|
return domain.Deck{}, nil |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
// GetByUser returns the decks of the given user. |
42
|
|
|
func (r *SQLRepository) GetByUser(_ context.Context, _ domain.User) ([]domain.Deck, error) { |
43
|
|
|
return []domain.Deck{}, nil |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
// GetByLearner returns the decks of the given learner. |
47
|
|
|
func (r *SQLRepository) GetByLearner(_ context.Context, _ domain.User) ([]domain.Deck, error) { |
48
|
|
|
return []domain.Deck{}, nil |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
// GetPublic returns the public decks. |
52
|
|
|
func (r *SQLRepository) GetPublic(_ context.Context) ([]domain.Deck, error) { |
53
|
|
|
return []domain.Deck{}, nil |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
// NewRepository returns a new repository. |
57
|
|
|
func NewRepository(dbConn *pgxpool.Pool) IRepository { |
58
|
|
|
q := db.New(dbConn) |
59
|
|
|
return &SQLRepository{q: q} |
60
|
|
|
} |
61
|
|
|
|