Remove index by obj; add distinct operator

This commit is contained in:
Daniel J. Summers 2022-05-18 10:32:42 -04:00
parent 19ee6a803a
commit e8f203ab5f
3 changed files with 17 additions and 17 deletions

View File

@ -118,14 +118,6 @@ type RethinkBuilder<'T> () =
[<CustomOperation "indexCreate">] [<CustomOperation "indexCreate">]
member _.IndexCreate (tbl, index, js, opts) = indexCreateJSWithOptArgs index js opts tbl member _.IndexCreate (tbl, index, js, opts) = indexCreateJSWithOptArgs index js opts tbl
/// Create an index for a table, using an object expression
[<CustomOperation "indexCreate">]
member _.IndexCreate (tbl, index, expr : obj) = indexCreateObj index expr tbl
/// Create an index for a table, using an object expression and optional arguments
[<CustomOperation "indexCreate">]
member _.IndexCreate (tbl, index, expr : obj, opts) = indexCreateObjWithOptArgs index expr opts tbl
/// Drop an index for a table /// Drop an index for a table
[<CustomOperation "indexDrop">] [<CustomOperation "indexDrop">]
member _.IndexDrop (tbl, index) = indexDrop index tbl member _.IndexDrop (tbl, index) = indexDrop index tbl
@ -188,6 +180,14 @@ type RethinkBuilder<'T> () =
[<CustomOperation "count">] [<CustomOperation "count">]
member _.Count (expr, js) = countJS js expr member _.Count (expr, js) = countJS js expr
/// Select distinct values from the sequence
[<CustomOperation "distinct">]
member _.Distinct expr = distinct expr
/// Select distinct values from the sequence using an index
[<CustomOperation "distinct">]
member _.Distinct (expr, index) = distinctWithIndex expr index
/// Filter a query by a single field value /// Filter a query by a single field value
[<CustomOperation "filter">] [<CustomOperation "filter">]
member _.Filter (expr, field, value) = filter (fieldsToMap [ field, value ]) expr member _.Filter (expr, field, value) = filter (fieldsToMap [ field, value ]) expr

View File

@ -187,6 +187,14 @@ let delete (expr : ReqlExpr) =
let deleteWithOptArgs args (expr : ReqlExpr) = let deleteWithOptArgs args (expr : ReqlExpr) =
delete expr |> DeleteOptArg.apply args delete expr |> DeleteOptArg.apply args
/// Only retrieve distinct entries from a selection
let distinct (expr : ReqlExpr) =
expr.Distinct ()
/// Only retrieve distinct entries from a selection, based on an index
let distinctWithIndex expr (index : string) =
(distinct expr).OptArg ("index", index)
/// EqJoin the left field on the right-hand table using its primary key /// EqJoin the left field on the right-hand table using its primary key
let eqJoin (field : string) (table : Table) (expr : ReqlExpr) = let eqJoin (field : string) (table : Table) (expr : ReqlExpr) =
expr.EqJoin (field, table) expr.EqJoin (field, table)
@ -279,14 +287,6 @@ let indexCreateJS (indexName : string) js (table : Table) =
let indexCreateJSWithOptArgs indexName js args table = let indexCreateJSWithOptArgs indexName js args table =
indexCreateJS indexName js table |> IndexCreateOptArg.apply args indexCreateJS indexName js table |> IndexCreateOptArg.apply args
/// Create an index on the given table using the give expression
let indexCreateObj (indexName : string) (expr : obj) (table : Table) =
table.IndexCreate (indexName, expr)
/// Create an index on the given table using the give expression, including optional arguments
let indexCreateObjWithOptArgs indexName (expr : obj) args table =
indexCreateObj indexName expr table |> IndexCreateOptArg.apply args
/// Drop an index /// Drop an index
let indexDrop (indexName : string) (table : Table) = let indexDrop (indexName : string) (table : Table) =
table.IndexDrop indexName table.IndexDrop indexName

View File

@ -11,7 +11,7 @@
<Copyright>See LICENSE</Copyright> <Copyright>See LICENSE</Copyright>
<PackageTags>RethinkDB document F#</PackageTags> <PackageTags>RethinkDB document F#</PackageTags>
<VersionPrefix>0.8.0</VersionPrefix> <VersionPrefix>0.8.0</VersionPrefix>
<VersionSuffix>alpha-0008</VersionSuffix> <VersionSuffix>alpha-0009</VersionSuffix>
<PackageReleaseNotes>Alpha; use at your own risk</PackageReleaseNotes> <PackageReleaseNotes>Alpha; use at your own risk</PackageReleaseNotes>
</PropertyGroup> </PropertyGroup>