Documentation ¶
Index ¶
- Variables
- func ConcatSlugPath(path ...string) string
- func ConcatSlugPathLower(path ...string) string
- func GenerateSecureRandBase64(numBytes int) (string, error)
- func IsValidSlugPath(path string) bool
- func MakeProjectionFromKeys(validKeys BSONKeySet, keys ...[]string) (bson.M, error)
- func SlugPathDepth(slugPath string) int
- 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 ¶
var ErrInvalidSlugPath = errors.New("Invalid slug path")
ErrInvalidSlugPath indicates an invalid slug path
Functions ¶
func ConcatSlugPath ¶ added in v1.6.0
ConcatSlugPath creates a slug path by concatenating the given path parts. Does not slugify the individual path parts.
func ConcatSlugPathLower ¶ added in v1.6.0
ConcatSlugPathLower is the same as ConcatSlugPathLower but converts it to lower-case
func GenerateSecureRandBase64 ¶ added in v0.11.0
GenerateSecureRandBase64 generates a cryptographically secure random number of the given size and encodes it in a base64 string.
func IsValidSlugPath ¶ added in v0.11.0
IsValidSlugPath checks that the path is valid, which means it must have both a beginning and trailing slash. The path must no empty parts (i.e. "//").
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 SlugPathDepth ¶ added in v0.11.0
SlugPathDepth returns the depth of the given slug path, which is the number of '/' separators in the path, ignoring the trailing slash
func SlugifyPath ¶
SlugifyPath converts the given path into a safe path with slug tokens. All slug paths begin and end with trailing slash.
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