forked from ravendb/ravendb-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
document_query_customization.go
74 lines (59 loc) · 2.8 KB
/
document_query_customization.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package ravendb
import "time"
// Note: in Java it's hidden behind IDocumentQueryCustomization
// DocumentQueryCustomization allows customizing query
type DocumentQueryCustomization struct {
query *abstractDocumentQuery
}
// GetQueryOperation returns raw query operation that will be sent to the server
func (d *DocumentQueryCustomization) GetQueryOperation() *queryOperation {
return d.query.queryOperation
}
// AddBeforeQueryExecutedListener allows you to modify index query before it's executed
func (d *DocumentQueryCustomization) AddBeforeQueryExecutedListener(action func(*IndexQuery)) int {
return d.query.addBeforeQueryExecutedListener(action)
}
// RemoveBeforeQueryExecutedListener removes listener added with AddBeforeQueryExecutedListener
func (d *DocumentQueryCustomization) RemoveBeforeQueryExecutedListener(idx int) {
d.query.removeBeforeQueryExecutedListener(idx)
}
// AddAfterQueryExecutedListener adds a callback to get the results of the query
func (d *DocumentQueryCustomization) AddAfterQueryExecutedListener(action func(*QueryResult)) int {
return d.query.addAfterQueryExecutedListener(action)
}
// RemoveAfterQueryExecutedListener removes callback added with AddAfterQueryExecutedListener
func (d *DocumentQueryCustomization) RemoveAfterQueryExecutedListener(idx int) {
d.query.removeAfterQueryExecutedListener(idx)
}
// AddAfterStreamExecutedCallback adds a callback to get stream result
func (d *DocumentQueryCustomization) AddAfterStreamExecutedCallback(action func(map[string]interface{})) int {
return d.query.addAfterStreamExecutedListener(action)
}
// RemoveAfterStreamExecutedCallback remove callback added with AddAfterStreamExecutedCallback
func (d *DocumentQueryCustomization) RemoveAfterStreamExecutedCallback(idx int) {
d.query.removeAfterStreamExecutedListener(idx)
}
// NoCaching disables caching for query results
func (d *DocumentQueryCustomization) NoCaching() {
d.query.noCaching()
}
// NoTracking disables tracking for quried entities by Raven's Unit of Work
// Using this option prevents hodling query results in memory
func (d *DocumentQueryCustomization) NoTracking() {
d.query.noTracking()
}
// RandomOrdering orders search results randomly.
func (d *DocumentQueryCustomization) RandomOrdering() {
d.query.randomOrdering()
}
// RandomOrdering orders search results randomly with a given seed.
// This is useful for repeatable random queries
func (d *DocumentQueryCustomization) RandomOrderingWithSeed(seed string) {
d.query.randomOrderingWithSeed(seed)
}
// WaitForNonStaleResults instructs the query to wait for non results.
// waitTimeout of 0 means infinite timeout
// This shouldn't be used outside of unit tests unless you are well aware of the implications
func (d *DocumentQueryCustomization) WaitForNonStaleResults(waitTimeout time.Duration) {
d.query.waitForNonStaleResults(waitTimeout)
}