bsonutil

package
v0.0.0-...-2a589a5 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: Apache-2.0 Imports: 4 Imported by: 103

Documentation

Overview

Package bsonutil provides a number of simple common utilities for interacting bson-tagged structs in go.

This code originates in the Evergreen project and is a centerpiece of that project's document mapping strategy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDottedKeyName

func GetDottedKeyName(fieldNames ...string) string

GetDottedKeyName assembles a key name, for use in queries, of a nested field name.

func MustHaveTag

func MustHaveTag(data interface{}, fieldName string) string

MustHaveTag gets the "bson" struct tag for a field, panicking if either the field does not exist or has no "bson" tag.

func Tag

func Tag(data interface{}, fieldName string) (string, error)

Tag returns the value of the "bson" tag for the given struct field name of the "data" struct, stripping any tag modifiers such as "omitempty". Returns the empty string if there is no tag, and an error if the field does not exist in the struct.

If data is a slice of structs, this check applies to the type of struct in the slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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