當前位置: 首頁>>代碼示例>>Golang>>正文


Golang gocbcore.SubDocOp類代碼示例

本文整理匯總了Golang中github.com/couchbase/gocb/gocbcore.SubDocOp的典型用法代碼示例。如果您正苦於以下問題:Golang SubDocOp類的具體用法?Golang SubDocOp怎麽用?Golang SubDocOp使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了SubDocOp類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Counter

// 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
}
開發者ID:tmichaud314,項目名稱:gocb,代碼行數:13,代碼來源:bucket_subdoc.go

示例2: ArrayAddUnique

// 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
}
開發者ID:tmichaud314,項目名稱:gocb,代碼行數:13,代碼來源:bucket_subdoc.go

示例3: ArrayInsert

// 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
}
開發者ID:tmichaud314,項目名稱:gocb,代碼行數:15,代碼來源:bucket_subdoc.go

示例4: ArrayAppend

// 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
}
開發者ID:tmichaud314,項目名稱:gocb,代碼行數:17,代碼來源:bucket_subdoc.go


注:本文中的github.com/couchbase/gocb/gocbcore.SubDocOp類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。