Documentation ¶
Index ¶
- func MakeProjectionFromKeys(validKeys BSONKeySet, keys ...[]string) (bson.M, error)
- func SlugifyPath(path string) string
- func SlugifyPathLower(path string) string
- func SlugifyToken(token string) string
- func SlugifyTokenLower(token string) string
- func WrapAsTransaction(ctx context.Context, mdb *mongo.Database, l *log.Entry, ...) (interface{}, bool, error)
- type BSONKeySet
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 ¶
SlugifyPath converts the given path into a safe path with slug tokens
func SlugifyPathLower ¶
SlugifyPathLower converts the given path into a safe path with lower-case slug tokens
func SlugifyToken ¶
SlugifyToken converts the given token into a safe slug string
func SlugifyTokenLower ¶
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 ¶
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