Remove generics from filter/insert/update
This commit is contained in:
parent
f23f7b90e9
commit
91febe04f4
@ -104,11 +104,11 @@ type RethinkBuilder<'T> () =
|
|||||||
|
|
||||||
/// Create an index for a table, using a function to calculate the index
|
/// Create an index for a table, using a function to calculate the index
|
||||||
[<CustomOperation "indexCreate">]
|
[<CustomOperation "indexCreate">]
|
||||||
member _.IndexCreate (tbl, index, f) = indexCreateFunc<'T> index f tbl
|
member _.IndexCreate (tbl, index, f) = indexCreateFunc index f tbl
|
||||||
|
|
||||||
/// Create an index for a table, using a function to calculate the index
|
/// Create an index for a table, using a function to calculate the index
|
||||||
[<CustomOperation "indexCreate">]
|
[<CustomOperation "indexCreate">]
|
||||||
member _.IndexCreate (tbl, index, f, opts) = indexCreateFuncWithOptArgs<'T> index f opts tbl
|
member _.IndexCreate (tbl, index, f, opts) = indexCreateFuncWithOptArgs index f opts tbl
|
||||||
|
|
||||||
/// Create an index for a table, using a JavaScript function to calculate the index
|
/// Create an index for a table, using a JavaScript function to calculate the index
|
||||||
[<CustomOperation "indexCreate">]
|
[<CustomOperation "indexCreate">]
|
||||||
@ -294,19 +294,19 @@ type RethinkBuilder<'T> () =
|
|||||||
|
|
||||||
/// Insert a document into the given table
|
/// Insert a document into the given table
|
||||||
[<CustomOperation "insert">]
|
[<CustomOperation "insert">]
|
||||||
member _.Insert (tbl, doc) = insert<'T> doc tbl
|
member _.Insert (tbl, doc : obj) = insert doc tbl
|
||||||
|
|
||||||
/// Insert multiple documents into the given table
|
/// Insert multiple documents into the given table
|
||||||
[<CustomOperation "insert">]
|
[<CustomOperation "insert">]
|
||||||
member _.Insert (tbl, doc) = insertMany<'T> (Seq.ofList doc) tbl
|
member _.Insert (tbl, doc) = insertMany (Seq.ofList doc) tbl
|
||||||
|
|
||||||
/// Insert a document into the given table, using optional arguments
|
/// Insert a document into the given table, using optional arguments
|
||||||
[<CustomOperation "insert">]
|
[<CustomOperation "insert">]
|
||||||
member _.Insert (tbl, docs, opts) = insertWithOptArgs<'T> docs opts tbl
|
member _.Insert (tbl, docs : obj, opts) = insertWithOptArgs docs opts tbl
|
||||||
|
|
||||||
/// Insert multiple documents into the given table, using optional arguments
|
/// Insert multiple documents into the given table, using optional arguments
|
||||||
[<CustomOperation "insert">]
|
[<CustomOperation "insert">]
|
||||||
member _.Insert (tbl, docs, opts) = insertManyWithOptArgs<'T> (Seq.ofList docs) opts tbl
|
member _.Insert (tbl, docs, opts) = insertManyWithOptArgs (Seq.ofList docs) opts tbl
|
||||||
|
|
||||||
/// Update specific fields in a document
|
/// Update specific fields in a document
|
||||||
[<CustomOperation "update">]
|
[<CustomOperation "update">]
|
||||||
@ -318,11 +318,11 @@ type RethinkBuilder<'T> () =
|
|||||||
|
|
||||||
/// Update specific fields in a document using a function
|
/// Update specific fields in a document using a function
|
||||||
[<CustomOperation "update">]
|
[<CustomOperation "update">]
|
||||||
member _.Update (expr, f) = updateFunc<'T> f expr
|
member _.Update (expr, f) = updateFunc f expr
|
||||||
|
|
||||||
/// Update specific fields in a document using a function, with optional arguments
|
/// Update specific fields in a document using a function, with optional arguments
|
||||||
[<CustomOperation "update">]
|
[<CustomOperation "update">]
|
||||||
member _.Update (expr, f, args) = updateFuncWithOptArgs<'T> f args expr
|
member _.Update (expr, f, args) = updateFuncWithOptArgs f args expr
|
||||||
|
|
||||||
/// Update specific fields in a document using a JavaScript function
|
/// Update specific fields in a document using a JavaScript function
|
||||||
[<CustomOperation "update">]
|
[<CustomOperation "update">]
|
||||||
@ -334,19 +334,19 @@ type RethinkBuilder<'T> () =
|
|||||||
|
|
||||||
/// Replace the current query with the specified document
|
/// Replace the current query with the specified document
|
||||||
[<CustomOperation "replace">]
|
[<CustomOperation "replace">]
|
||||||
member _.Replace (expr, doc) = replace<'T> doc expr
|
member _.Replace (expr, doc : obj) = replace doc expr
|
||||||
|
|
||||||
/// Replace the current query with the specified document, using optional arguments
|
/// Replace the current query with the specified document, using optional arguments
|
||||||
[<CustomOperation "replace">]
|
[<CustomOperation "replace">]
|
||||||
member _.Replace (expr, doc, args) = replaceWithOptArgs<'T> doc args expr
|
member _.Replace (expr, doc : obj, args) = replaceWithOptArgs doc args expr
|
||||||
|
|
||||||
/// Replace the current query with document(s) created by a function
|
/// Replace the current query with document(s) created by a function
|
||||||
[<CustomOperation "replace">]
|
[<CustomOperation "replace">]
|
||||||
member _.Replace (expr, f) = replaceFunc<'T> f expr
|
member _.Replace (expr, f) = replaceFunc f expr
|
||||||
|
|
||||||
/// Replace the current query with document(s) created by a function, using optional arguments
|
/// Replace the current query with document(s) created by a function, using optional arguments
|
||||||
[<CustomOperation "replace">]
|
[<CustomOperation "replace">]
|
||||||
member _.Replace (expr, f, args) = replaceFuncWithOptArgs<'T> f args expr
|
member _.Replace (expr, f, args) = replaceFuncWithOptArgs f args expr
|
||||||
|
|
||||||
/// Replace the current query with document(s) created by a JavaScript function
|
/// Replace the current query with document(s) created by a JavaScript function
|
||||||
[<CustomOperation "replace">]
|
[<CustomOperation "replace">]
|
||||||
|
@ -13,6 +13,7 @@ module private Helpers =
|
|||||||
/// Create a Javascript object from a string (used mostly for type inference)
|
/// Create a Javascript object from a string (used mostly for type inference)
|
||||||
let toJS (js : string) = Javascript js
|
let toJS (js : string) = Javascript js
|
||||||
|
|
||||||
|
// ~~ EXECUTION ~~
|
||||||
|
|
||||||
/// Get a cursor with the results of an expression
|
/// Get a cursor with the results of an expression
|
||||||
let asyncCursor<'T> conn (expr : ReqlExpr) =
|
let asyncCursor<'T> conn (expr : ReqlExpr) =
|
||||||
@ -132,6 +133,8 @@ let syncResult<'T> conn expr =
|
|||||||
let syncResultWithOptArgs<'T> args conn expr =
|
let syncResultWithOptArgs<'T> args conn expr =
|
||||||
asyncResultWithOptArgs<'T> args conn expr |> Async.RunSynchronously
|
asyncResultWithOptArgs<'T> args conn expr |> Async.RunSynchronously
|
||||||
|
|
||||||
|
// ~~ QUERY DEFINITION ~~
|
||||||
|
|
||||||
/// Get documents between a lower bound and an upper bound based on a primary key
|
/// Get documents between a lower bound and an upper bound based on a primary key
|
||||||
let between (lowerKey : obj) (upperKey : obj) (expr : ReqlExpr) =
|
let between (lowerKey : obj) (upperKey : obj) (expr : ReqlExpr) =
|
||||||
expr.Between (lowerKey, upperKey)
|
expr.Between (lowerKey, upperKey)
|
||||||
@ -217,15 +220,15 @@ let filterWithOptArgs (filterSpec : obj) arg expr =
|
|||||||
filter filterSpec expr |> FilterOptArg.apply arg
|
filter filterSpec expr |> FilterOptArg.apply arg
|
||||||
|
|
||||||
/// Filter documents using a function
|
/// Filter documents using a function
|
||||||
let filterFunc (f : ReqlExpr -> bool) (expr : ReqlExpr) =
|
let filterFunc f (expr : ReqlExpr) =
|
||||||
expr.Filter (ReqlFunction1 (fun row -> f row :> obj))
|
expr.Filter (ReqlFunction1 f)
|
||||||
|
|
||||||
/// Filter documents using a function, providing optional arguments
|
/// Filter documents using a function, providing optional arguments
|
||||||
let filterFuncWithOptArgs f arg expr =
|
let filterFuncWithOptArgs f arg expr =
|
||||||
filterFunc f expr |> FilterOptArg.apply arg
|
filterFunc f expr |> FilterOptArg.apply arg
|
||||||
|
|
||||||
/// Filter documents using multiple functions (has the effect of ANDing them)
|
/// Filter documents using multiple functions (has the effect of ANDing them)
|
||||||
let filterFuncAll (fs : (ReqlExpr -> bool) list) (expr : ReqlExpr) =
|
let filterFuncAll fs expr =
|
||||||
(fs |> List.fold (fun (e : ReqlExpr) f -> filterFunc f e) expr) :?> Filter
|
(fs |> List.fold (fun (e : ReqlExpr) f -> filterFunc f e) expr) :?> Filter
|
||||||
|
|
||||||
/// Filter documents using multiple functions (has the effect of ANDing them), providing optional arguments
|
/// Filter documents using multiple functions (has the effect of ANDing them), providing optional arguments
|
||||||
@ -261,11 +264,11 @@ let indexCreateWithOptArgs (indexName : string) args (table : Table) =
|
|||||||
indexCreate indexName table |> IndexCreateOptArg.apply args
|
indexCreate indexName table |> IndexCreateOptArg.apply args
|
||||||
|
|
||||||
/// Create an index on the given table using a function
|
/// Create an index on the given table using a function
|
||||||
let indexCreateFunc<'T> (indexName : string) (f : ReqlExpr -> 'T) (table : Table) =
|
let indexCreateFunc (indexName : string) f (table : Table) =
|
||||||
table.IndexCreate (indexName, ReqlFunction1 (fun row -> f row :> obj))
|
table.IndexCreate (indexName, ReqlFunction1 f)
|
||||||
|
|
||||||
/// Create an index on the given table using a function, including optional arguments
|
/// Create an index on the given table using a function, including optional arguments
|
||||||
let indexCreateFuncWithOptArgs<'T> indexName (f : ReqlExpr -> 'T) args table =
|
let indexCreateFuncWithOptArgs indexName f args table =
|
||||||
indexCreateFunc indexName f table |> IndexCreateOptArg.apply args
|
indexCreateFunc indexName f table |> IndexCreateOptArg.apply args
|
||||||
|
|
||||||
/// Create an index on the given table using JavaScript
|
/// Create an index on the given table using JavaScript
|
||||||
@ -317,19 +320,19 @@ let innerJoinJS (otherSeq : obj) js (expr : ReqlExpr) =
|
|||||||
expr.InnerJoin (otherSeq, toJS js)
|
expr.InnerJoin (otherSeq, toJS js)
|
||||||
|
|
||||||
/// Insert a single document (use insertMany for multiple)
|
/// Insert a single document (use insertMany for multiple)
|
||||||
let insert<'T> (doc : 'T) (table : Table) =
|
let insert (doc : obj) (table : Table) =
|
||||||
table.Insert doc
|
table.Insert doc
|
||||||
|
|
||||||
/// Insert multiple documents
|
/// Insert multiple documents
|
||||||
let insertMany<'T> (docs : 'T seq) (table : Table) =
|
let insertMany (docs : obj seq) (table : Table) =
|
||||||
table.Insert (Array.ofSeq docs)
|
table.Insert (Array.ofSeq docs)
|
||||||
|
|
||||||
/// Insert a single document, providing optional arguments (use insertManyWithOptArgs for multiple)
|
/// Insert a single document, providing optional arguments (use insertManyWithOptArgs for multiple)
|
||||||
let insertWithOptArgs<'T> (doc : 'T) args table =
|
let insertWithOptArgs (doc : obj) args table =
|
||||||
insert doc table |> InsertOptArg.apply args
|
insert doc table |> InsertOptArg.apply args
|
||||||
|
|
||||||
/// Insert multiple documents, providing optional arguments
|
/// Insert multiple documents, providing optional arguments
|
||||||
let insertManyWithOptArgs<'T> (docs : 'T seq) args table =
|
let insertManyWithOptArgs (docs : obj seq) args table =
|
||||||
insertMany docs table |> InsertOptArg.apply args
|
insertMany docs table |> InsertOptArg.apply args
|
||||||
|
|
||||||
/// Test whether a sequence is empty
|
/// Test whether a sequence is empty
|
||||||
@ -409,19 +412,19 @@ let pluck (fields : string seq) (expr : ReqlExpr) =
|
|||||||
expr.Pluck (Array.ofSeq fields)
|
expr.Pluck (Array.ofSeq fields)
|
||||||
|
|
||||||
/// Replace documents
|
/// Replace documents
|
||||||
let replace<'T> (replaceSpec : 'T) (expr : ReqlExpr) =
|
let replace (replaceSpec : obj) (expr : ReqlExpr) =
|
||||||
expr.Replace replaceSpec
|
expr.Replace replaceSpec
|
||||||
|
|
||||||
/// Replace documents, providing optional arguments
|
/// Replace documents, providing optional arguments
|
||||||
let replaceWithOptArgs<'T> (replaceSpec : 'T) args expr =
|
let replaceWithOptArgs (replaceSpec : obj) args expr =
|
||||||
replace replaceSpec expr |> ReplaceOptArg.apply args
|
replace replaceSpec expr |> ReplaceOptArg.apply args
|
||||||
|
|
||||||
/// Replace documents using a function
|
/// Replace documents using a function
|
||||||
let replaceFunc<'T> (f : ReqlExpr -> 'T) (expr : ReqlExpr) =
|
let replaceFunc f (expr : ReqlExpr) =
|
||||||
expr.Replace (ReqlFunction1 (fun row -> f row :> obj))
|
expr.Replace (ReqlFunction1 f)
|
||||||
|
|
||||||
/// Replace documents using a function, providing optional arguments
|
/// Replace documents using a function, providing optional arguments
|
||||||
let replaceFuncWithOptArgs<'T> (f : ReqlExpr -> 'T) args expr =
|
let replaceFuncWithOptArgs f args expr =
|
||||||
replaceFunc f expr |> ReplaceOptArg.apply args
|
replaceFunc f expr |> ReplaceOptArg.apply args
|
||||||
|
|
||||||
/// Replace documents using JavaScript
|
/// Replace documents using JavaScript
|
||||||
@ -473,19 +476,19 @@ let tableListFromDefault () =
|
|||||||
r.TableList ()
|
r.TableList ()
|
||||||
|
|
||||||
/// Update documents
|
/// Update documents
|
||||||
let update<'T> (updateSpec : 'T) (expr : ReqlExpr) =
|
let update (updateSpec : obj) (expr : ReqlExpr) =
|
||||||
expr.Update updateSpec
|
expr.Update updateSpec
|
||||||
|
|
||||||
/// Update documents, providing optional arguments
|
/// Update documents, providing optional arguments
|
||||||
let updateWithOptArgs<'T> (updateSpec : 'T) args expr =
|
let updateWithOptArgs (updateSpec : obj) args expr =
|
||||||
update updateSpec expr |> UpdateOptArg.apply args
|
update updateSpec expr |> UpdateOptArg.apply args
|
||||||
|
|
||||||
/// Update documents using a function
|
/// Update documents using a function
|
||||||
let updateFunc<'T> (f : ReqlExpr -> 'T) (expr : ReqlExpr) =
|
let updateFunc f (expr : ReqlExpr) =
|
||||||
expr.Update (ReqlFunction1 (fun row -> f row :> obj))
|
expr.Update (ReqlFunction1 f)
|
||||||
|
|
||||||
/// Update documents using a function, providing optional arguments
|
/// Update documents using a function, providing optional arguments
|
||||||
let updateFuncWithOptArgs<'T> (f : ReqlExpr -> 'T) args expr =
|
let updateFuncWithOptArgs f args expr =
|
||||||
updateFunc f expr |> UpdateOptArg.apply args
|
updateFunc f expr |> UpdateOptArg.apply args
|
||||||
|
|
||||||
/// Update documents using JavaScript
|
/// Update documents using JavaScript
|
||||||
@ -504,7 +507,6 @@ let without (columns : string seq) (expr : ReqlExpr) =
|
|||||||
let zip (expr : ReqlExpr) =
|
let zip (expr : ReqlExpr) =
|
||||||
expr.Zip ()
|
expr.Zip ()
|
||||||
|
|
||||||
|
|
||||||
// ~~ RETRY ~~
|
// ~~ RETRY ~~
|
||||||
|
|
||||||
open RethinkDb.Driver.Net
|
open RethinkDb.Driver.Net
|
||||||
|
@ -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-0006</VersionSuffix>
|
<VersionSuffix>alpha-0007</VersionSuffix>
|
||||||
<PackageReleaseNotes>Alpha; use at your own risk</PackageReleaseNotes>
|
<PackageReleaseNotes>Alpha; use at your own risk</PackageReleaseNotes>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user