utils

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeProjectionFromKeys

func MakeProjectionFromKeys(validKeys BSONKeySet, keys ...[]string) (bson.M, error)

MakeProjectionFromKeys creates a projection document based on the given keys, optionally performing validation.

func SlugifyPath

func SlugifyPath(path string) string

SlugifyPath converts the given path into a safe path with slug tokens

func SlugifyPathLower

func SlugifyPathLower(path string) string

SlugifyPathLower converts the given path into a safe path with lower-case slug tokens

func SlugifyToken

func SlugifyToken(token string) string

SlugifyToken converts the given token into a safe slug string

func SlugifyTokenLower

func SlugifyTokenLower(token string) string

SlugifyTokenLower converts the given token into a safe, lower-case slug string

func WrapAsTransaction added in v0.10.0

func WrapAsTransaction(ctx context.Context, mdb *mongo.Database, l *log.Entry, transactionCb func(ctx mongo.SessionContext) (interface{}, error)) (interface{}, bool, error)

WrapAsTransaction creates or reuses an existing transaction session. Returns transaction-ret-val, completed, error; where completed is a booleal indicating if the transaction is done (i.e. this is not part of a bigger transaction)

Types

type BSONKeySet

type BSONKeySet map[string]bool

BSONKeySet holds a set of valid BSON keys

func CombineBSONKeys

func CombineBSONKeys(allKeys ...BSONKeySet) BSONKeySet

CombineBSONKeys combines multiple BSONKeySets together. They must not have the same keys.

func ExtractBSONKeys

func ExtractBSONKeys(v interface{}) BSONKeySet

ExtractBSONKeys returns a map of all the BSON keys tagged on the given type

func PrefixBSONKeys

func PrefixBSONKeys(keys BSONKeySet, prefix string) BSONKeySet

PrefixBSONKeys adds the given prefix to all keys in the set

Jump to

Keyboard shortcuts

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