forked from ravendb/ravendb-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjson_extensions.go
49 lines (42 loc) · 1.08 KB
/
json_extensions.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
47
48
49
package ravendb
func jsonExtensionsWriteIndexQuery(conventions *DocumentConventions, query *IndexQuery) map[string]interface{} {
res := map[string]interface{}{}
res["Query"] = query.query
if query.pageSize > 0 {
res["PageSize"] = query.pageSize
}
if query.waitForNonStaleResults {
res["WaitForNonStaleResults"] = query.waitForNonStaleResults
}
if query.start > 0 {
res["Start"] = query.start
}
if query.waitForNonStaleResultsTimeout != 0 {
s := durationToTimeSpan(query.waitForNonStaleResultsTimeout)
res["WaitForNonStaleResultsTimeout"] = s
}
if query.disableCaching {
res["DisableCaching"] = query.disableCaching
}
if query.skipDuplicateChecking {
res["SkipDuplicateChecking"] = query.skipDuplicateChecking
}
params := query.queryParameters
if params != nil {
res["QueryParameters"] = convertEntityToJSON(params, nil)
} else {
res["QueryParameters"] = nil
}
return res
}
func tryGetConflict(metadata map[string]interface{}) bool {
v, ok := metadata[MetadataConflict]
if !ok {
return false
}
b, ok := v.(bool)
if !ok {
return false
}
return b
}