From e8f203ab5f30eede5d08d295c24f5b40c04c1cbb Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Wed, 18 May 2022 10:32:42 -0400 Subject: [PATCH] Remove index by obj; add distinct operator --- src/RethinkDb.Driver.FSharp/Builder.fs | 16 ++++++++-------- src/RethinkDb.Driver.FSharp/Functions.fs | 16 ++++++++-------- .../RethinkDb.Driver.FSharp.fsproj | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/RethinkDb.Driver.FSharp/Builder.fs b/src/RethinkDb.Driver.FSharp/Builder.fs index cd566f0..f7889d6 100644 --- a/src/RethinkDb.Driver.FSharp/Builder.fs +++ b/src/RethinkDb.Driver.FSharp/Builder.fs @@ -118,14 +118,6 @@ type RethinkBuilder<'T> () = [] member _.IndexCreate (tbl, index, js, opts) = indexCreateJSWithOptArgs index js opts tbl - /// Create an index for a table, using an object expression - [] - member _.IndexCreate (tbl, index, expr : obj) = indexCreateObj index expr tbl - - /// Create an index for a table, using an object expression and optional arguments - [] - member _.IndexCreate (tbl, index, expr : obj, opts) = indexCreateObjWithOptArgs index expr opts tbl - /// Drop an index for a table [] member _.IndexDrop (tbl, index) = indexDrop index tbl @@ -188,6 +180,14 @@ type RethinkBuilder<'T> () = [] member _.Count (expr, js) = countJS js expr + /// Select distinct values from the sequence + [] + member _.Distinct expr = distinct expr + + /// Select distinct values from the sequence using an index + [] + member _.Distinct (expr, index) = distinctWithIndex expr index + /// Filter a query by a single field value [] member _.Filter (expr, field, value) = filter (fieldsToMap [ field, value ]) expr diff --git a/src/RethinkDb.Driver.FSharp/Functions.fs b/src/RethinkDb.Driver.FSharp/Functions.fs index 9f1d52b..2b89b1a 100644 --- a/src/RethinkDb.Driver.FSharp/Functions.fs +++ b/src/RethinkDb.Driver.FSharp/Functions.fs @@ -187,6 +187,14 @@ let delete (expr : ReqlExpr) = let deleteWithOptArgs args (expr : ReqlExpr) = 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 let eqJoin (field : string) (table : Table) (expr : ReqlExpr) = expr.EqJoin (field, table) @@ -279,14 +287,6 @@ let indexCreateJS (indexName : string) js (table : Table) = let indexCreateJSWithOptArgs indexName js args table = 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 let indexDrop (indexName : string) (table : Table) = table.IndexDrop indexName diff --git a/src/RethinkDb.Driver.FSharp/RethinkDb.Driver.FSharp.fsproj b/src/RethinkDb.Driver.FSharp/RethinkDb.Driver.FSharp.fsproj index a5a2b9e..e4da046 100644 --- a/src/RethinkDb.Driver.FSharp/RethinkDb.Driver.FSharp.fsproj +++ b/src/RethinkDb.Driver.FSharp/RethinkDb.Driver.FSharp.fsproj @@ -11,7 +11,7 @@ See LICENSE RethinkDB document F# 0.8.0 - alpha-0008 + alpha-0009 Alpha; use at your own risk