Add update/replace by function to CE

This commit is contained in:
Daniel J. Summers 2022-04-21 09:13:44 -04:00
parent 7b26b8b43c
commit 78e5bbf77d
2 changed files with 38 additions and 1 deletions

View File

@ -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
[<CustomOperation "update">]
member _.Update (expr : ReqlExpr, f : ReqlExpr -> obj) = expr.Update (ReqlFunction1 f)
/// Update specific fields in a document using a function, with optional arguments
[<CustomOperation "update">]
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
[<CustomOperation "update">]
member _.Update (expr : ReqlExpr, js : string) = expr.Update (Javascript js)
/// Update specific fields in a document using a JavaScript function, with optional arguments
[<CustomOperation "update">]
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
[<CustomOperation "replace">]
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
[<CustomOperation "replace">]
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
[<CustomOperation "replace">]
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
[<CustomOperation "replace">]
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
[<CustomOperation "replace">]
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
[<CustomOperation "delete">]
member _.Delete (expr : ReqlExpr) = expr.Delete ()

View File

@ -12,7 +12,7 @@
<Copyright>See LICENSE</Copyright>
<PackageTags>RethinkDB document F#</PackageTags>
<VersionPrefix>0.8.0</VersionPrefix>
<VersionSuffix>alpha-0003</VersionSuffix>
<VersionSuffix>alpha-0005</VersionSuffix>
</PropertyGroup>
<ItemGroup>
@ -28,6 +28,7 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Polly" Version="7.2.3" />
<PackageReference Include="RethinkDb.Driver" Version="2.*" />
<PackageReference Update="FSharp.Core" Version="6.0.3" />
</ItemGroup>
</Project>