mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 19:14:23 +00:00
d8e42744b4
* fix: move eventstore pkgs * fix: move eventstore pkgs * fix: remove v2 view * fix: remove v2 view
35 lines
1001 B
Go
35 lines
1001 B
Go
package view
|
|
|
|
import (
|
|
"github.com/caos/zitadel/internal/errors"
|
|
es_models "github.com/caos/zitadel/internal/eventstore/v1/models"
|
|
"github.com/caos/zitadel/internal/user/repository/eventsourcing/model"
|
|
)
|
|
|
|
func UserByIDQuery(id string, latestSequence uint64) (*es_models.SearchQuery, error) {
|
|
if id == "" {
|
|
return nil, errors.ThrowPreconditionFailed(nil, "EVENT-d8isw", "Errors.User.UserIDMissing")
|
|
}
|
|
return UserQuery(latestSequence).
|
|
AggregateIDFilter(id), nil
|
|
}
|
|
|
|
func UserQuery(latestSequence uint64) *es_models.SearchQuery {
|
|
return es_models.NewSearchQuery().
|
|
AggregateTypeFilter(model.UserAggregate).
|
|
LatestSequenceFilter(latestSequence)
|
|
}
|
|
|
|
func ChangesQuery(userID string, latestSequence, limit uint64, sortAscending bool) *es_models.SearchQuery {
|
|
query := es_models.NewSearchQuery().
|
|
AggregateTypeFilter(model.UserAggregate)
|
|
if !sortAscending {
|
|
query.OrderDesc()
|
|
}
|
|
|
|
query.LatestSequenceFilter(latestSequence).
|
|
AggregateIDFilter(userID).
|
|
SetLimit(limit)
|
|
return query
|
|
}
|