本文整理匯總了Golang中github.com/couchbase/query/expression.Function.Name方法的典型用法代碼示例。如果您正苦於以下問題:Golang Function.Name方法的具體用法?Golang Function.Name怎麽用?Golang Function.Name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/couchbase/query/expression.Function
的用法示例。
在下文中一共展示了Function.Name方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: VisitFunction
// Function
func (this *JSConverter) VisitFunction(expr expression.Function) (interface{}, error) {
var buf bytes.Buffer
functionExpr := &funcExpr{operands: list.New()}
//buf.WriteString("(")
var nopush bool
var nobracket bool
var pushOperands bool
var writeLater bool
var functionName string
switch strings.ToLower(expr.Name()) {
case "lower":
functionName = ".toLowerCase()"
writeLater = true
case "upper":
functionName = ".toUpperCase()"
writeLater = true
case "object_length":
fallthrough
case "array_length":
fallthrough
case "poly_length":
fallthrough
case "string_length":
fallthrough
case "length":
functionName = ".length"
writeLater = true
case "str_to_millis":
fallthrough
case "millis":
nopush = true
buf.WriteString("Date.parse(")
case "contains":
functionExpr.name = ".indexOf("
this.stack.Push(functionExpr)
pushOperands = true
case "substr":
functionExpr.name = ".substring("
this.stack.Push(functionExpr)
pushOperands = true
case "now_millis":
buf.WriteString("Date.now().toString()")
case "meta":
buf.WriteString("meta")
nobracket = true
default:
nopush = true
buf.WriteString(expr.Name())
buf.WriteString("(")
}
var firstOp expression.Expression
for i, op := range expr.Operands() {
if pushOperands == true {
if i == 0 {
firstOp = op
continue
} else {
functionExpr.operands.PushBack(op)
}
} else {
if i > 0 {
buf.WriteString(", ")
}
if op == nil {
buf.WriteString("*") // for count(*)
} else {
buf.WriteString(this.Visit(op))
}
}
}
if firstOp != nil {
buf.WriteString(this.Visit(firstOp))
}
if nopush == true && nobracket == false {
buf.WriteString(")")
}
if writeLater == true {
buf.WriteString(functionName)
}
return buf.String(), nil
}