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 ¶
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 ¶
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"