Skip to content

Commit 2c58fec

Browse files
committed
Add UnionWithOpts term
1 parent 38f30ca commit 2c58fec

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
44

55
## Unreleased
66

7+
### Added
8+
- Added `UnionWithOpts` term which allows `Union` to be called with optional arguments (such as `Interleave`)
9+
710
### Fixed
811
- Fixed error when connecting to database as non-admin user
912

query_transformation.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,15 @@ func (t Term) IsEmpty(args ...interface{}) Term {
151151
return constructMethodTerm(t, "IsEmpty", p.Term_IS_EMPTY, args, map[string]interface{}{})
152152
}
153153

154+
// UnionOpts contains the optional arguments for the Slice term
155+
type UnionOpts struct {
156+
Interleave interface{} `gorethink:"interleave,omitempty"`
157+
}
158+
159+
func (o *UnionOpts) toMap() map[string]interface{} {
160+
return optArgsToMap(o)
161+
}
162+
154163
// Union concatenates two sequences.
155164
func Union(args ...interface{}) Term {
156165
return constructRootTerm("Union", p.Term_UNION, args, map[string]interface{}{})
@@ -161,6 +170,18 @@ func (t Term) Union(args ...interface{}) Term {
161170
return constructMethodTerm(t, "Union", p.Term_UNION, args, map[string]interface{}{})
162171
}
163172

173+
// UnionWithOpts like Union concatenates two sequences however allows for optional
174+
// arguments to be passed.
175+
func UnionWithOpts(optArgs UnionOpts, args ...interface{}) Term {
176+
return constructRootTerm("Union", p.Term_UNION, args, optArgs.toMap())
177+
}
178+
179+
// UnionWithOpts like Union concatenates two sequences however allows for optional
180+
// arguments to be passed.
181+
func (t Term) UnionWithOpts(optArgs UnionOpts, args ...interface{}) Term {
182+
return constructMethodTerm(t, "Union", p.Term_UNION, args, optArgs.toMap())
183+
}
184+
164185
// Sample selects a given number of elements from a sequence with uniform random
165186
// distribution. Selection is done without replacement.
166187
func (t Term) Sample(args ...interface{}) Term {

0 commit comments

Comments
 (0)