queries

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

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

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 CountResponsesByContent(collection data.Collection, objectID string) (mapof.Int, error)

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 GroupBy added in v0.6.0

func GroupBy(collection data.Collection, pipeline []bson.M) (mapof.Int, error)

GroupBy returns amap of counts, grouped by the provided pipeline

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 MessageMarkRead(inboxCollection data.Collection, userID primitive.ObjectID, messageID primitive.ObjectID) error

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

func UpgradeMongoDB added in v0.6.0

func UpgradeMongoDB(connectionString string, databaseName string, domain *model.Domain) error

Types

type Counter added in v0.6.0

type Counter struct {
	Count int `bson:"count"`
}

type GroupedCounter added in v0.6.0

type GroupedCounter struct {
	Group string `bson:"_id"`
	Count int    `bson:"count"`
}

type MaxRankResult

type MaxRankResult struct {
	MaxRank int `bson:"maxRank"`
}

MaxRankResult defines the results of the custom MaxRank query

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL