Skip to content

Commit 00561cc

Browse files
committed
Added the Index optarg to Distinct
1 parent 2ad5b34 commit 00561cc

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

query_aggregation.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,21 @@ func (t Term) Reduce(args ...interface{}) Term {
1313
return constructMethodTerm(t, "Reduce", p.Term_REDUCE, funcWrapArgs(args), map[string]interface{}{})
1414
}
1515

16+
type DistinctOpts struct {
17+
Index interface{} `gorethink:"index,omitempty"`
18+
}
19+
20+
func (o *DistinctOpts) toMap() map[string]interface{} {
21+
return optArgsToMap(o)
22+
}
23+
1624
// Remove duplicate elements from the sequence.
17-
func (t Term) Distinct(args ...interface{}) Term {
18-
return constructMethodTerm(t, "Distinct", p.Term_DISTINCT, args, map[string]interface{}{})
25+
func (t Term) Distinct(optArgs ...DistinctOpts) Term {
26+
opts := map[string]interface{}{}
27+
if len(optArgs) >= 1 {
28+
opts = optArgs[0].toMap()
29+
}
30+
return constructMethodTerm(t, "Distinct", p.Term_DISTINCT, []interface{}, opts)
1931
}
2032

2133
// Takes a stream and partitions it into multiple groups based on the

query_table.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ func (o *IndexRenameOpts) toMap() map[string]interface{} {
102102
// new name will be deleted and the index will be renamed. If overwrite is False
103103
// (the default) an error will be raised if the new index name already exists.
104104
func (t Term) IndexRename(oldName, newName interface{}, optArgs ...IndexRenameOpts) Term {
105-
return constructMethodTerm(t, "IndexRename", p.Term_INDEX_RENAME, []interface{}{oldName, newName}, map[string]interface{}{})
105+
opts := map[string]interface{}{}
106+
if len(optArgs) >= 1 {
107+
opts = optArgs[0].toMap()
108+
}
109+
return constructMethodTerm(t, "IndexRename", p.Term_INDEX_RENAME, []interface{}{oldName, newName}, opts)
106110
}
107111

108112
// Get the status of the specified indexes on this table, or the status of all

0 commit comments

Comments
 (0)