Пример #1
0
// 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
}
Пример #2
0
// 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
}
Пример #3
0
// 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
}