а
Size: a a a
а
а
а
ВС
ВС
Д
type PostsRepository interface {в
GetPosts(ctx context.Context, тут_хз_что) ([]Post, error)
}
тут_хз_что
нужно передать что-то, что будет влиять на выборку. Что передавать туда?Д
AS
type PostsRepository interface {в
GetPosts(ctx context.Context, тут_хз_что) ([]Post, error)
}
тут_хз_что
нужно передать что-то, что будет влиять на выборку. Что передавать туда?AS
AS
Д
type PostQueryConditions struct {
AfterID uuid.UUID
IsActive bool
Votes int
AuthorizedUserID uuid.UUID
}
if pqc.IsActive {
query = query.Where("is_active", true)
}
if !pqc.AfterID.IsNil() {
query = query.Where("id > $", pqc.AfterID)
}
if pqc.Votes > 0 {
query = query.Where("votes > $", pqc.Votes)
}
...
а
type PostQueryConditions struct {
AfterID uuid.UUID
IsActive bool
Votes int
AuthorizedUserID uuid.UUID
}
if pqc.IsActive {
query = query.Where("is_active", true)
}
if !pqc.AfterID.IsNil() {
query = query.Where("id > $", pqc.AfterID)
}
if pqc.Votes > 0 {
query = query.Where("votes > $", pqc.Votes)
}
...