forked from couchbase/gocb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
n1qlquery.go
46 lines (39 loc) · 966 Bytes
/
n1qlquery.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package gocb
type ConsistencyMode int
const (
NotBounded = ConsistencyMode(1)
RequestPlus = ConsistencyMode(2)
StatementPlus = ConsistencyMode(3)
)
type N1qlQuery struct {
options map[string]interface{}
adHoc bool
}
func (nq *N1qlQuery) Consistency(stale ConsistencyMode) *N1qlQuery {
if stale == NotBounded {
nq.options["consistency"] = "not_bounded"
} else if stale == RequestPlus {
nq.options["consistency"] = "request_plus"
} else if stale == StatementPlus {
nq.options["consistency"] = "statement_plus"
} else {
panic("Unexpected consistency option")
}
return nq
}
func (nq *N1qlQuery) AdHoc(adhoc bool) *N1qlQuery {
nq.adHoc = adhoc;
return nq
}
func (nq *N1qlQuery) Custom(name, value string) *N1qlQuery {
nq.options[name] = value
return nq
}
func NewN1qlQuery(statement string) *N1qlQuery {
nq := &N1qlQuery{
options: make(map[string]interface{}),
adHoc: true,
}
nq.options["statement"] = statement
return nq
}