spec

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package spec defines the ESpec (Entity Specification) Type, which can be used for queries, and update operations on the general Entity.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ESpec

type ESpec struct {
	/*
		Field is the database eField-name to constrain
		the search
	*/
	Field string `json:"eField"`
	/*
		Target specifies the value to query in the
		constrained eField
	*/
	Target interface{} `json:"target"`
	/*
		UpdateOperator specifies an update operator for
		this ESpec
	*/
	UpdateOperator string `json:"updateOperator"`
	/*
		QueryOperator specified a query operator for
		this ESpec
	*/
	QueryOperator string `json:"queryOperator"`
}

ESpec is a format which can be used to specify fields and values for entities. This is useful when constructing queries, as well as when specifying changes.

Ensure that Specs intended for update operations have the zero value for the QueryOperator eField and vice versa.

func (*ESpec) ToBSON

func (s *ESpec) ToBSON() bson.M

ToBSON encodes the ESpec as BSON map which can be used as a query filter. For now, only use this with MongoDB comparison operators as they have a consistent syntax.

func (*ESpec) ToUpdateSpec

func (s *ESpec) ToUpdateSpec() bson.M

ToUpdateSpec returns a BSON map which can be used as an update document. The ESpec's Operator eField must be a valid Mongo update operator.

The following update operators are used in the context of other operators and are not supported:

"$(update)", "$[]", "$[<identifier>]",
"$slice", "$sort", "$each", "$position"

Jump to

Keyboard shortcuts

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