Skip to content

Commit d081629

Browse files
committed
Rename GetByIDs() to ListByIDs()
1 parent 9df208d commit d081629

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

table.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ func (t *Table[T, PT, IDT]) GetByID(ctx context.Context, id IDT) (PT, error) {
124124
return t.Get(ctx, sq.Eq{t.IDColumn: id}, []string{t.IDColumn})
125125
}
126126

127-
// GetByIDs returns records by their IDs.
128-
func (t *Table[T, PT, IDT]) GetByIDs(ctx context.Context, ids []IDT) ([]PT, error) {
127+
// ListByIDs returns records by their IDs.
128+
func (t *Table[T, PT, IDT]) ListByIDs(ctx context.Context, ids []IDT) ([]PT, error) {
129129
return t.List(ctx, sq.Eq{t.IDColumn: ids}, nil)
130130
}
131131

tests/table_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ func TestTable(t *testing.T) {
109109
require.Equal(t, article.DeletedAt, articleCheck.DeletedAt, "Article DeletedAt should match")
110110
}
111111

112-
// Verify we can load all articles with .GetByIDs()
112+
// Verify we can load all articles with .ListByIDs()
113113
articleIDs := make([]uint64, len(articles))
114114
for _, article := range articles {
115115
articleIDs = append(articleIDs, article.ID)
116116
}
117-
articlesCheck, err := tx.Articles.GetByIDs(ctx, articleIDs)
118-
require.NoError(t, err, "GetByIDs failed")
117+
articlesCheck, err := tx.Articles.ListByIDs(ctx, articleIDs)
118+
require.NoError(t, err, "ListByIDs failed")
119119
require.Equal(t, len(articles), len(articlesCheck), "Number of articles should match")
120120
for i, _ := range articlesCheck {
121121
require.Equal(t, articles[i].ID, articlesCheck[i].ID, "Article ID should match")

tests/tables_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type reviewsTable struct {
2121
*pgkit.Table[Review, *Review, uint64]
2222
}
2323

24-
func (w *reviewsTable) DequeueForProcessing(ctx context.Context, limit uint64) ([]*Review, error) {
24+
func (t *reviewsTable) DequeueForProcessing(ctx context.Context, limit uint64) ([]*Review, error) {
2525
var dequeued []*Review
2626
where := sq.Eq{
2727
"status": ReviewStatusPending,
@@ -31,7 +31,7 @@ func (w *reviewsTable) DequeueForProcessing(ctx context.Context, limit uint64) (
3131
"created_at ASC",
3232
}
3333

34-
err := w.LockForUpdates(ctx, where, orderBy, limit, func(reviews []*Review) {
34+
err := t.LockForUpdates(ctx, where, orderBy, limit, func(reviews []*Review) {
3535
now := time.Now().UTC()
3636
for _, review := range reviews {
3737
review.Status = ReviewStatusProcessing

0 commit comments

Comments
 (0)