From 78e5bbf77d13728146264da941dadd5983d6ba53 Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Thu, 21 Apr 2022 09:13:44 -0400 Subject: [PATCH] Add update/replace by function to CE --- src/RethinkDb.Driver.FSharp/Builder.fs | 36 +++++++++++++++++++ .../RethinkDb.Driver.FSharp.fsproj | 3 +- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/RethinkDb.Driver.FSharp/Builder.fs b/src/RethinkDb.Driver.FSharp/Builder.fs index fa52b0e..4f5592a 100644 --- a/src/RethinkDb.Driver.FSharp/Builder.fs +++ b/src/RethinkDb.Driver.FSharp/Builder.fs @@ -273,6 +273,24 @@ type RethinkBuilder<'T> () = member this.Update (expr : ReqlExpr, fields : (string * obj) list, args : UpdateOptArg list) = this.Update (expr, fields) |> UpdateOptArg.apply args + /// Update specific fields in a document using a function + [] + member _.Update (expr : ReqlExpr, f : ReqlExpr -> obj) = expr.Update (ReqlFunction1 f) + + /// Update specific fields in a document using a function, with optional arguments + [] + member this.Update (expr : ReqlExpr, f : ReqlExpr -> obj, args : UpdateOptArg list) = + this.Update (expr, f) |> UpdateOptArg.apply args + + /// Update specific fields in a document using a JavaScript function + [] + member _.Update (expr : ReqlExpr, js : string) = expr.Update (Javascript js) + + /// Update specific fields in a document using a JavaScript function, with optional arguments + [] + member this.Update (expr : ReqlExpr, js : string, args : UpdateOptArg list) = + this.Update (expr, js) |> UpdateOptArg.apply args + /// Replace the current query with the specified document [] member _.Replace (expr : ReqlExpr, doc : obj) = expr.Replace doc @@ -282,6 +300,24 @@ type RethinkBuilder<'T> () = member this.Replace (expr : ReqlExpr, doc : obj, args : ReplaceOptArg list) = this.Replace (expr, doc) |> ReplaceOptArg.apply args + /// Replace the current query with document(s) created by a function + [] + member _.Replace (expr : ReqlExpr, f : ReqlExpr -> obj) = expr.Replace (ReqlFunction1 f) + + /// Replace the current query with document(s) created by a function, using optional arguments + [] + member this.Replace (expr : ReqlExpr, f : ReqlExpr -> obj, args : ReplaceOptArg list) = + this.Replace (expr, f) |> ReplaceOptArg.apply args + + /// Replace the current query with document(s) created by a JavaScript function + [] + member _.Replace (expr : ReqlExpr, js : string) = expr.Replace (Javascript js) + + /// Replace the current query with document(s) created by a JavaScript function, using optional arguments + [] + member this.Replace (expr : ReqlExpr, js : string, args : ReplaceOptArg list) = + this.Replace (expr, js) |> ReplaceOptArg.apply args + /// Delete the document(s) identified by the current query [] member _.Delete (expr : ReqlExpr) = expr.Delete () diff --git a/src/RethinkDb.Driver.FSharp/RethinkDb.Driver.FSharp.fsproj b/src/RethinkDb.Driver.FSharp/RethinkDb.Driver.FSharp.fsproj index 34d17f1..511239a 100644 --- a/src/RethinkDb.Driver.FSharp/RethinkDb.Driver.FSharp.fsproj +++ b/src/RethinkDb.Driver.FSharp/RethinkDb.Driver.FSharp.fsproj @@ -12,7 +12,7 @@ See LICENSE RethinkDB document F# 0.8.0 - alpha-0003 + alpha-0005 @@ -28,6 +28,7 @@ +