builder

package
v0.0.0-...-b6e0fdc Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ASSET_SRC_PUBLIC_INCLUDE_FIELDS = []string{"details", "asset_type"}

	// this is the projection for after source lookup
	ASSET_PUBLIC_PROJECTION = map[string]string{
		"avatar":      "$source.details.avatar",
		"source":      "$source.details.source",
		"asset_type":  "$source.asset_type",
		"file_name":   "$file_name",
		"description": "$description",
		"tags":        "$tags",
		"created_at":  "$created_at",
		"updated_at":  "$updated_at",
	}
)
View Source
var (
	PUBLIC_INCLUDE_FIELDS = []string{"name", "style", "role", "status"}
)

Functions

func BsonA

func BsonA(vals []any) bson.A

Create a bson.A - takes an array of any type, each will be inserted into the bson.A as itself

func BsonD

func BsonD(k string, v any) bson.D

Creates a bson.D with a single key/value pair of bson.E values

func BsonE

func BsonE(k string, v any) bson.E

Creates a bson.E with the given key/value pair

func BsonLookup

func BsonLookup(col, pk, fk, as string, let bson.D, pipe bson.A) bson.D

Creates a $lookup bson obj with given parameters

func BsonOperWithArray

func BsonOperWithArray(op string, v []any) bson.D

same as BsonOperator but for operators that take an array instead of bson

func BsonOperator

func BsonOperator(op string, k string, v any) bson.D

creates bson for pipeline operators

func BsonProjection

func BsonProjection(keys []string, val BSONProjectValue) bson.D

Creates a bson projection with keys either included or excluded with inclusion, exclusions are explicit. the inverse is true of exclusions

func BsonProjectionMap

func BsonProjectionMap[T comparable](vals map[string]T) bson.D

creates a projection map from a map[string]T - for more specific control over the projection

func ComposeBsonD

func ComposeBsonD[T comparable](vals map[string]T) bson.D

Creates a bson.D including the given key/value pair map as bson.E values

func QrStrAddCreatorOnThread

func QrStrAddCreatorOnThread() bson.D

returns the bson.D pipeline obj to unflatten the creator field back into an object

func QrStrEntireThread

func QrStrEntireThread(slug string, cfg *types.QueryCtx) bson.A

a single thread with all posts populated

func QrStrFindHashCollision

func QrStrFindHashCollision(hash string, method string) bson.D

Checksum hash collision query - checks source and avatar for given hash using specified method

func QrStrLookupAccount

func QrStrLookupAccount(pk string) bson.D

account lookup pipeline

func QrStrLookupAccountRecentIdentities

func QrStrLookupAccountRecentIdentities(account_id primitive.ObjectID) bson.A

10 most recent account identities

func QrStrLookupArticle

func QrStrLookupArticle(slug string) bson.A

single article with populated comments

func QrStrLookupArticleAuthor

func QrStrLookupArticleAuthor(pk string) bson.D

article author lookup

func QrStrLookupArticleList

func QrStrLookupArticleList(cfg *types.QueryCtx) bson.A

list of paginated articles

func QrStrLookupAssets

func QrStrLookupAssets(pk string) bson.D

func QrStrLookupIdentity

func QrStrLookupIdentity(pk string) bson.D

returns a pipeline object that can be used as an internal pipeline for a $lookup or other aggregate pk is the field name to reference the lookup from

func QrStrLookupPost

func QrStrLookupPost(threadID primitive.ObjectID, postNum int, threadSlug, boardShort string) bson.A

singular post lookup

func QrStrLookupPosts

func QrStrLookupPosts(sortBy string, sortDir int, limit int) bson.D

Thread posts aggregation lookup pipeline

func QrStrLookupThread

func QrStrLookupThread(slug string, boardID primitive.ObjectID, boardShort string) bson.A

singular thread lookup - models in the shape of post

func QrStrLookupThreads

func QrStrLookupThreads(boardID primitive.ObjectID, cfg *types.QueryCtx) (bson.A, error)

List of paginated thread previews for a board

func StartPaginatedPipe

func StartPaginatedPipe(mkey string, mval primitive.ObjectID, cfg *types.QueryCtx) (bson.A, error)

starts a paginated pipeline with a match on the given key/value pair

Types

type BSONProjectValue

type BSONProjectValue int
const (
	BSONProjectInclude BSONProjectValue = 1
	BSONProjectExclude BSONProjectValue = -1
)

Jump to

Keyboard shortcuts

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