Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FieldOPType ¶
type FieldOPType string
FieldOPType is the field operator passed in the Update API
type FieldOperator ¶
type FieldOperator struct { Op FieldOPType Document jsoniter.RawMessage }
A FieldOperator can be of the following type: { "$set": { <field1>: <value1>, ... } } { "$incr": { <field1>: <value> } } { "$remove": ["d"] }
func NewFieldOperator ¶
func NewFieldOperator(op FieldOPType, val jsoniter.RawMessage) *FieldOperator
NewFieldOperator returns a FieldOperator
func (*FieldOperator) DeserializeDoc ¶
func (f *FieldOperator) DeserializeDoc() (interface{}, error)
type FieldOperatorFactory ¶
type FieldOperatorFactory struct {
FieldOperators map[string]*FieldOperator
}
The FieldOperatorFactory has all the field operators passed in the Update API request. The factory implements a MergeAndGet method to convert the input to the output JSON that needs to be persisted in the database.
func BuildFieldOperators ¶
func BuildFieldOperators(reqFields []byte) (*FieldOperatorFactory, error)
BuildFieldOperators un-marshals request "fields" present in the Update API and returns a FieldOperatorFactory The FieldOperatorFactory has the logic to remove/merge the JSON passed in the input and the one present in the database.
func (*FieldOperatorFactory) MergeAndGet ¶
func (factory *FieldOperatorFactory) MergeAndGet(existingDoc jsoniter.RawMessage) (jsoniter.RawMessage, error)
MergeAndGet method to converts the input to the output after applying all the operators.