Documentation ¶
Overview ¶
Package queries contains all of the custom queries required by this application that DO NOT run through the standard `data` package. These are queries that rely on specific features of the database (such as mongodb aggregation, or live queries) that are out of scope for the data package
If this application is ever migrated from mongodb, these functions will need to be rewritten to match the new database API.
This package is an abberation in the "Clean Architecture" design pattern (https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html), but it is useful for now in order to maintain some flexibility in the database.
Index ¶
- func Aggregate[T any](ctx context.Context, collection *mongo.Collection, pipeline []bson.M, ...) ([]T, error)
- func CountResponsesByContent(collection data.Collection, objectID string) (mapof.Int, error)
- func FolderSetUnreadCount(collection data.Collection, userID primitive.ObjectID, ...) error
- func GroupBy(collection data.Collection, pipeline []bson.M) (mapof.Int, error)
- func MaxRank(ctx context.Context, collection data.Collection, parentID primitive.ObjectID) (int, error)
- func MessageMarkRead(inboxCollection data.Collection, userID primitive.ObjectID, ...) error
- func RawUpdate(ctx context.Context, collection data.Collection, criteria exp.Expression, ...) error
- func SearchActivityStreamActors(ctx context.Context, collection data.Collection, text string) ([]model.ActorSummary, error)
- func SetFollowersCount(userCollection data.Collection, followersCollection data.Collection, ...) error
- func SetFollowingCount(userCollection data.Collection, followingCollection data.Collection, ...) error
- func SetRuleCount(userCollection data.Collection, ruleCollection data.Collection, ...) error
- func UpgradeMongoDB(connectionString string, databaseName string, domain *model.Domain) error
- type Counter
- type GroupedCounter
- type MaxRankResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Aggregate ¶ added in v0.6.0
func Aggregate[T any](ctx context.Context, collection *mongo.Collection, pipeline []bson.M, opts ...*options.AggregateOptions) ([]T, error)
Aggregate returns amap of counts, grouped by the provided pipeline
func CountResponsesByContent ¶ added in v0.6.0
func FolderSetUnreadCount ¶ added in v0.6.0
func FolderSetUnreadCount(collection data.Collection, userID primitive.ObjectID, folderID primitive.ObjectID, unreadCount int) error
FolderSetUnreadCount updates the "readDate" field on a folder, if the new value is greater than the existing value.
func MaxRank ¶
func MaxRank(ctx context.Context, collection data.Collection, parentID primitive.ObjectID) (int, error)
MaxRank returns the maximum rank of all children of the parent stream
func MessageMarkRead ¶ added in v0.6.0
func RawUpdate ¶
func RawUpdate(ctx context.Context, collection data.Collection, criteria exp.Expression, update bson.M) error
func SearchActivityStreamActors ¶ added in v0.6.0
func SearchActivityStreamActors(ctx context.Context, collection data.Collection, text string) ([]model.ActorSummary, error)
SearchActivityStreamActors full-text searches the ActivityStream cache for all Actors matching the search query.
func SetFollowersCount ¶
func SetFollowersCount(userCollection data.Collection, followersCollection data.Collection, userID primitive.ObjectID) error
SetFollowersCount counts the number of Followers for a specific User and updates the User record.
func SetFollowingCount ¶
func SetFollowingCount(userCollection data.Collection, followingCollection data.Collection, userID primitive.ObjectID) error
func SetRuleCount ¶ added in v0.6.0
func SetRuleCount(userCollection data.Collection, ruleCollection data.Collection, userID primitive.ObjectID) error
Types ¶
type GroupedCounter ¶ added in v0.6.0
type MaxRankResult ¶
type MaxRankResult struct {
MaxRank int `bson:"maxRank"`
}
MaxRankResult defines the results of the custom MaxRank query