// Adds an counter operation to this mutation operation set. func (set *MutateInBuilder) Counter(path string, delta int64, createParents bool) *MutateInBuilder { op := gocbcore.SubDocOp{ Op: gocbcore.SubDocOpCounter, Path: path, } op.Value, _ = json.Marshal(delta) if createParents { op.Flags |= gocbcore.SubDocFlagMkDirP } set.ops = append(set.ops, op) return set }
// Adds an dictionary add unique operation to this mutation operation set. func (set *MutateInBuilder) ArrayAddUnique(path string, value interface{}, createParents bool) *MutateInBuilder { op := gocbcore.SubDocOp{ Op: gocbcore.SubDocOpArrayAddUnique, Path: path, } op.Value, _ = json.Marshal(value) if createParents { op.Flags |= gocbcore.SubDocFlagMkDirP } set.ops = append(set.ops, op) return set }
// Inserts an element at a given position within an array. The position should be // specified as part of the path, e.g. path.to.array[3] func (set *MutateInBuilder) ArrayInsert(path string, value interface{}) *MutateInBuilder { op := gocbcore.SubDocOp{ Op: gocbcore.SubDocOpArrayInsert, Path: path, } if multiVal, isMulti := value.(subDocMultiValue); isMulti { op.Value = multiVal } else { op.Value, _ = json.Marshal(value) } set.ops = append(set.ops, op) return set }
// Adds an element to the end (i.e. right) of an array func (set *MutateInBuilder) ArrayAppend(path string, value interface{}, createParents bool) *MutateInBuilder { op := gocbcore.SubDocOp{ Op: gocbcore.SubDocOpArrayPushLast, Path: path, } if multiVal, isMulti := value.(subDocMultiValue); isMulti { op.Value = multiVal } else { op.Value, _ = json.Marshal(value) } if createParents { op.Flags |= gocbcore.SubDocFlagMkDirP } set.ops = append(set.ops, op) return set }