common

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

common package contains functions from internal/db which need to be shared commonly with other packages that have a cyclic dependency on internal/db like internal/oplog.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidParameter is returned when a required parameter is nil.
	ErrInvalidParameter = errors.New("nil parameter")
)

Functions

func BuildUpdatePaths

func BuildUpdatePaths(fieldValues map[string]interface{}, fieldMask []string, allowZeroFields []string) (masks []string, nulls []string)

BuildUpdatePaths takes a map of field names to field values, field masks, fields allowed to be zero value, and returns both a list of field names to udpate and a list of field names that should be set to null.

func Intersection

func Intersection(av, bv []string) ([]string, map[string]string, map[string]string, error)

Intersection is a case-insensitive search for intersecting values. Returns []string of the Intersection with values in lowercase, and map[string]string of the original av and bv, with the key set to uppercase and value set to the original

func UpdateFields

func UpdateFields(i interface{}, fieldMaskPaths []string, setToNullPaths []string) (map[string]interface{}, error)

UpdateFields will create a map[string]interface of the update values to be sent to the db. The map keys will be the field names for the fields to be updated. The caller provided fieldMaskPaths and setToNullPaths must not intersect. fieldMaskPaths and setToNullPaths cannot both be zero len.

Types

This section is empty.

Jump to

Keyboard shortcuts

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