V3 rc2 (#2)
- Implements `Field` type for by-field actions (**BREAKING**) - Adds `RemoveFields*` functions/methods for removing fields from documents
This commit was merged in pull request #2.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<PackageReleaseNotes>Initial release; migrated from BitBadger.Npgsql.Documents, with field and extension additions (RC 1)</PackageReleaseNotes>
|
||||
<PackageReleaseNotes>Adds Field type for by-field operations (BREAKING from rc-1); adds RemoveFields* functions</PackageReleaseNotes>
|
||||
<PackageTags>JSON Document PostgreSQL Npgsql</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -50,8 +50,8 @@ module Extensions =
|
||||
WithProps.Count.all tableName (Sql.existingConnection conn)
|
||||
|
||||
/// Count matching documents using a JSON field comparison query (->> =)
|
||||
member conn.countByField tableName fieldName op (value: obj) =
|
||||
WithProps.Count.byField tableName fieldName op value (Sql.existingConnection conn)
|
||||
member conn.countByField tableName field =
|
||||
WithProps.Count.byField tableName field (Sql.existingConnection conn)
|
||||
|
||||
/// Count matching documents using a JSON containment query (@>)
|
||||
member conn.countByContains tableName criteria =
|
||||
@@ -66,8 +66,8 @@ module Extensions =
|
||||
WithProps.Exists.byId tableName docId (Sql.existingConnection conn)
|
||||
|
||||
/// Determine if documents exist using a JSON field comparison query (->> =)
|
||||
member conn.existsByField tableName fieldName op (value: obj) =
|
||||
WithProps.Exists.byField tableName fieldName op value (Sql.existingConnection conn)
|
||||
member conn.existsByField tableName field =
|
||||
WithProps.Exists.byField tableName field (Sql.existingConnection conn)
|
||||
|
||||
/// Determine if documents exist using a JSON containment query (@>)
|
||||
member conn.existsByContains tableName criteria =
|
||||
@@ -86,8 +86,8 @@ module Extensions =
|
||||
WithProps.Find.byId<'TKey, 'TDoc> tableName docId (Sql.existingConnection conn)
|
||||
|
||||
/// Retrieve documents matching a JSON field comparison query (->> =)
|
||||
member conn.findByField<'TDoc> tableName fieldName op (value: obj) =
|
||||
WithProps.Find.byField<'TDoc> tableName fieldName op value (Sql.existingConnection conn)
|
||||
member conn.findByField<'TDoc> tableName field =
|
||||
WithProps.Find.byField<'TDoc> tableName field (Sql.existingConnection conn)
|
||||
|
||||
/// Retrieve documents matching a JSON containment query (@>)
|
||||
member conn.findByContains<'TDoc> tableName (criteria: obj) =
|
||||
@@ -98,8 +98,8 @@ module Extensions =
|
||||
WithProps.Find.byJsonPath<'TDoc> tableName jsonPath (Sql.existingConnection conn)
|
||||
|
||||
/// Retrieve the first document matching a JSON field comparison query (->> =); returns None if not found
|
||||
member conn.findFirstByField<'TDoc> tableName fieldName op (value: obj) =
|
||||
WithProps.Find.firstByField<'TDoc> tableName fieldName op value (Sql.existingConnection conn)
|
||||
member conn.findFirstByField<'TDoc> tableName field =
|
||||
WithProps.Find.firstByField<'TDoc> tableName field (Sql.existingConnection conn)
|
||||
|
||||
/// Retrieve the first document matching a JSON containment query (@>); returns None if not found
|
||||
member conn.findFirstByContains<'TDoc> tableName (criteria: obj) =
|
||||
@@ -122,8 +122,8 @@ module Extensions =
|
||||
WithProps.Patch.byId tableName docId patch (Sql.existingConnection conn)
|
||||
|
||||
/// Patch documents using a JSON field comparison query in the WHERE clause (->> =)
|
||||
member conn.patchByField tableName fieldName op (value: obj) (patch: 'TPatch) =
|
||||
WithProps.Patch.byField tableName fieldName op value patch (Sql.existingConnection conn)
|
||||
member conn.patchByField tableName field (patch: 'TPatch) =
|
||||
WithProps.Patch.byField tableName field patch (Sql.existingConnection conn)
|
||||
|
||||
/// Patch documents using a JSON containment query in the WHERE clause (@>)
|
||||
member conn.patchByContains tableName (criteria: 'TCriteria) (patch: 'TPatch) =
|
||||
@@ -133,13 +133,29 @@ module Extensions =
|
||||
member conn.patchByJsonPath tableName jsonPath (patch: 'TPatch) =
|
||||
WithProps.Patch.byJsonPath tableName jsonPath patch (Sql.existingConnection conn)
|
||||
|
||||
/// Remove fields from a document by the document's ID
|
||||
member conn.removeFieldsById tableName (docId: 'TKey) fieldNames =
|
||||
WithProps.RemoveFields.byId tableName docId fieldNames (Sql.existingConnection conn)
|
||||
|
||||
/// Remove fields from documents via a comparison on a JSON field in the document
|
||||
member conn.removeFieldsByField tableName field fieldNames =
|
||||
WithProps.RemoveFields.byField tableName field fieldNames (Sql.existingConnection conn)
|
||||
|
||||
/// Remove fields from documents via a JSON containment query (@>)
|
||||
member conn.removeFieldsByContains tableName (criteria: 'TContains) fieldNames =
|
||||
WithProps.RemoveFields.byContains tableName criteria fieldNames (Sql.existingConnection conn)
|
||||
|
||||
/// Remove fields from documents via a JSON Path match query (@?)
|
||||
member conn.removeFieldsByJsonPath tableName jsonPath fieldNames =
|
||||
WithProps.RemoveFields.byJsonPath tableName jsonPath fieldNames (Sql.existingConnection conn)
|
||||
|
||||
/// Delete a document by its ID
|
||||
member conn.deleteById tableName (docId: 'TKey) =
|
||||
WithProps.Delete.byId tableName docId (Sql.existingConnection conn)
|
||||
|
||||
/// Delete documents by matching a JSON field comparison query (->> =)
|
||||
member conn.deleteByField tableName fieldName op (value: obj) =
|
||||
WithProps.Delete.byField tableName fieldName op value (Sql.existingConnection conn)
|
||||
member conn.deleteByField tableName field =
|
||||
WithProps.Delete.byField tableName field (Sql.existingConnection conn)
|
||||
|
||||
/// Delete documents by matching a JSON containment query (@>)
|
||||
member conn.deleteByContains tableName (criteria: 'TContains) =
|
||||
@@ -209,8 +225,8 @@ type NpgsqlConnectionCSharpExtensions =
|
||||
|
||||
/// Count matching documents using a JSON field comparison query (->> =)
|
||||
[<Extension>]
|
||||
static member inline CountByField(conn, tableName, fieldName, op, value: obj) =
|
||||
WithProps.Count.byField tableName fieldName op value (Sql.existingConnection conn)
|
||||
static member inline CountByField(conn, tableName, field) =
|
||||
WithProps.Count.byField tableName field (Sql.existingConnection conn)
|
||||
|
||||
/// Count matching documents using a JSON containment query (@>)
|
||||
[<Extension>]
|
||||
@@ -229,8 +245,8 @@ type NpgsqlConnectionCSharpExtensions =
|
||||
|
||||
/// Determine if documents exist using a JSON field comparison query (->> =)
|
||||
[<Extension>]
|
||||
static member inline ExistsByField(conn, tableName, fieldName, op, value: obj) =
|
||||
WithProps.Exists.byField tableName fieldName op value (Sql.existingConnection conn)
|
||||
static member inline ExistsByField(conn, tableName, field) =
|
||||
WithProps.Exists.byField tableName field (Sql.existingConnection conn)
|
||||
|
||||
/// Determine if documents exist using a JSON containment query (@>)
|
||||
[<Extension>]
|
||||
@@ -254,8 +270,8 @@ type NpgsqlConnectionCSharpExtensions =
|
||||
|
||||
/// Retrieve documents matching a JSON field comparison query (->> =)
|
||||
[<Extension>]
|
||||
static member inline FindByField<'TDoc>(conn, tableName, fieldName, op, value: obj) =
|
||||
WithProps.Find.ByField<'TDoc>(tableName, fieldName, op, value, Sql.existingConnection conn)
|
||||
static member inline FindByField<'TDoc>(conn, tableName, field) =
|
||||
WithProps.Find.ByField<'TDoc>(tableName, field, Sql.existingConnection conn)
|
||||
|
||||
/// Retrieve documents matching a JSON containment query (@>)
|
||||
[<Extension>]
|
||||
@@ -269,8 +285,8 @@ type NpgsqlConnectionCSharpExtensions =
|
||||
|
||||
/// Retrieve the first document matching a JSON field comparison query (->> =); returns None if not found
|
||||
[<Extension>]
|
||||
static member inline FindFirstByField<'TDoc when 'TDoc: null>(conn, tableName, fieldName, op, value: obj) =
|
||||
WithProps.Find.FirstByField<'TDoc>(tableName, fieldName, op, value, Sql.existingConnection conn)
|
||||
static member inline FindFirstByField<'TDoc when 'TDoc: null>(conn, tableName, field) =
|
||||
WithProps.Find.FirstByField<'TDoc>(tableName, field, Sql.existingConnection conn)
|
||||
|
||||
/// Retrieve the first document matching a JSON containment query (@>); returns None if not found
|
||||
[<Extension>]
|
||||
@@ -299,8 +315,8 @@ type NpgsqlConnectionCSharpExtensions =
|
||||
|
||||
/// Patch documents using a JSON field comparison query in the WHERE clause (->> =)
|
||||
[<Extension>]
|
||||
static member inline PatchByField(conn, tableName, fieldName, op, value: obj, patch: 'TPatch) =
|
||||
WithProps.Patch.byField tableName fieldName op value patch (Sql.existingConnection conn)
|
||||
static member inline PatchByField(conn, tableName, field, patch: 'TPatch) =
|
||||
WithProps.Patch.byField tableName field patch (Sql.existingConnection conn)
|
||||
|
||||
/// Patch documents using a JSON containment query in the WHERE clause (@>)
|
||||
[<Extension>]
|
||||
@@ -312,6 +328,26 @@ type NpgsqlConnectionCSharpExtensions =
|
||||
static member inline PatchByJsonPath(conn, tableName, jsonPath, patch: 'TPatch) =
|
||||
WithProps.Patch.byJsonPath tableName jsonPath patch (Sql.existingConnection conn)
|
||||
|
||||
/// Remove fields from a document by the document's ID
|
||||
[<Extension>]
|
||||
static member inline RemoveFieldsById(conn, tableName, docId: 'TKey, fieldNames) =
|
||||
WithProps.RemoveFields.ById(tableName, docId, fieldNames, Sql.existingConnection conn)
|
||||
|
||||
/// Remove fields from documents via a comparison on a JSON field in the document
|
||||
[<Extension>]
|
||||
static member inline RemoveFieldsByField(conn, tableName, field, fieldNames) =
|
||||
WithProps.RemoveFields.ByField(tableName, field, fieldNames, Sql.existingConnection conn)
|
||||
|
||||
/// Remove fields from documents via a JSON containment query (@>)
|
||||
[<Extension>]
|
||||
static member inline RemoveFieldsByContains(conn, tableName, criteria: 'TContains, fieldNames) =
|
||||
WithProps.RemoveFields.ByContains(tableName, criteria, fieldNames, Sql.existingConnection conn)
|
||||
|
||||
/// Remove fields from documents via a JSON Path match query (@?)
|
||||
[<Extension>]
|
||||
static member inline RemoveFieldsByJsonPath(conn, tableName, jsonPath, fieldNames) =
|
||||
WithProps.RemoveFields.ByJsonPath(tableName, jsonPath, fieldNames, Sql.existingConnection conn)
|
||||
|
||||
/// Delete a document by its ID
|
||||
[<Extension>]
|
||||
static member inline DeleteById(conn, tableName, docId: 'TKey) =
|
||||
@@ -319,8 +355,8 @@ type NpgsqlConnectionCSharpExtensions =
|
||||
|
||||
/// Delete documents by matching a JSON field comparison query (->> =)
|
||||
[<Extension>]
|
||||
static member inline DeleteByField(conn, tableName, fieldName, op, value: obj) =
|
||||
WithProps.Delete.byField tableName fieldName op value (Sql.existingConnection conn)
|
||||
static member inline DeleteByField(conn, tableName, field) =
|
||||
WithProps.Delete.byField tableName field (Sql.existingConnection conn)
|
||||
|
||||
/// Delete documents by matching a JSON containment query (@>)
|
||||
[<Extension>]
|
||||
|
||||
@@ -64,10 +64,29 @@ module Parameters =
|
||||
name, Sql.jsonb (Configuration.serializer().Serialize it)
|
||||
|
||||
/// Create a JSON field parameter (name "@field")
|
||||
[<CompiledName "Field">]
|
||||
let fieldParam (value: obj) =
|
||||
"@field", Sql.parameter (NpgsqlParameter("@field", value))
|
||||
[<CompiledName "FSharpAddField">]
|
||||
let addFieldParam name field parameters =
|
||||
match field.Op with
|
||||
| EX | NEX -> parameters
|
||||
| _ -> (name, Sql.parameter (NpgsqlParameter(name, field.Value))) :: parameters
|
||||
|
||||
/// Create a JSON field parameter (name "@field")
|
||||
let AddField name field parameters =
|
||||
match field.Op with
|
||||
| EX | NEX -> parameters
|
||||
| _ -> (name, Sql.parameter (NpgsqlParameter(name, field.Value))) |> Seq.singleton |> Seq.append parameters
|
||||
|
||||
/// Append JSON field name parameters for the given field names to the given parameters
|
||||
[<CompiledName "FSharpFieldName">]
|
||||
let fieldNameParam (fieldNames: string list) =
|
||||
if fieldNames.Length = 1 then "@name", Sql.string fieldNames[0]
|
||||
else "@name", Sql.stringArray (Array.ofList fieldNames)
|
||||
|
||||
/// Append JSON field name parameters for the given field names to the given parameters
|
||||
let FieldName(fieldNames: string seq) =
|
||||
if Seq.isEmpty fieldNames then "@name", Sql.string (Seq.head fieldNames)
|
||||
else "@name", Sql.stringArray (Array.ofSeq fieldNames)
|
||||
|
||||
/// An empty parameter sequence
|
||||
[<CompiledName "None">]
|
||||
let noParams =
|
||||
@@ -145,25 +164,56 @@ module Query =
|
||||
/// Queries to patch (partially update) documents
|
||||
module Patch =
|
||||
|
||||
/// Create an UPDATE statement to patch documents
|
||||
let private update tableName whereClause =
|
||||
$"UPDATE %s{tableName} SET data = data || @data WHERE {whereClause}"
|
||||
|
||||
/// Query to patch a document by its ID
|
||||
[<CompiledName "ById">]
|
||||
let byId tableName =
|
||||
$"""UPDATE %s{tableName} SET data = data || @data WHERE {Query.whereById "@id"}"""
|
||||
Query.whereById "@id" |> update tableName
|
||||
|
||||
/// Query to patch documents match a JSON field comparison (->> =)
|
||||
[<CompiledName "ByField">]
|
||||
let byField tableName fieldName op =
|
||||
$"""UPDATE %s{tableName} SET data = data || @data WHERE {Query.whereByField fieldName op "@field"}"""
|
||||
let byField tableName field =
|
||||
Query.whereByField field "@field" |> update tableName
|
||||
|
||||
/// Query to patch documents matching a JSON containment query (@>)
|
||||
[<CompiledName "ByContains">]
|
||||
let byContains tableName =
|
||||
$"""UPDATE %s{tableName} SET data = data || @data WHERE {whereDataContains "@criteria"}"""
|
||||
whereDataContains "@criteria" |> update tableName
|
||||
|
||||
/// Query to patch documents matching a JSON containment query (@>)
|
||||
[<CompiledName "ByJsonPath">]
|
||||
let byJsonPath tableName =
|
||||
$"""UPDATE %s{tableName} SET data = data || @data WHERE {whereJsonPathMatches "@path"}"""
|
||||
whereJsonPathMatches "@path" |> update tableName
|
||||
|
||||
/// Queries to remove fields from documents
|
||||
module RemoveFields =
|
||||
|
||||
/// Create an UPDATE statement to remove parameters
|
||||
let private update tableName whereClause =
|
||||
$"UPDATE %s{tableName} SET data = data - @name WHERE {whereClause}"
|
||||
|
||||
/// Query to remove fields from a document by the document's ID
|
||||
[<CompiledName "ById">]
|
||||
let byId tableName =
|
||||
Query.whereById "@id" |> update tableName
|
||||
|
||||
/// Query to remove fields from documents via a comparison on a JSON field within the document
|
||||
[<CompiledName "ByField">]
|
||||
let byField tableName field =
|
||||
Query.whereByField field "@field" |> update tableName
|
||||
|
||||
/// Query to patch documents matching a JSON containment query (@>)
|
||||
[<CompiledName "ByContains">]
|
||||
let byContains tableName =
|
||||
whereDataContains "@criteria" |> update tableName
|
||||
|
||||
/// Query to patch documents matching a JSON containment query (@>)
|
||||
[<CompiledName "ByJsonPath">]
|
||||
let byJsonPath tableName =
|
||||
whereJsonPathMatches "@path" |> update tableName
|
||||
|
||||
/// Queries to delete documents
|
||||
module Delete =
|
||||
@@ -302,8 +352,8 @@ module WithProps =
|
||||
|
||||
/// Count matching documents using a JSON field comparison (->> =)
|
||||
[<CompiledName "ByField">]
|
||||
let byField tableName fieldName op (value: obj) sqlProps =
|
||||
Custom.scalar (Query.Count.byField tableName fieldName op) [ fieldParam value ] toCount sqlProps
|
||||
let byField tableName field sqlProps =
|
||||
Custom.scalar (Query.Count.byField tableName field) (addFieldParam "@field" field []) toCount sqlProps
|
||||
|
||||
/// Count matching documents using a JSON containment query (@>)
|
||||
[<CompiledName "ByContains">]
|
||||
@@ -326,8 +376,8 @@ module WithProps =
|
||||
|
||||
/// Determine if a document exists using a JSON field comparison (->> =)
|
||||
[<CompiledName "ByField">]
|
||||
let byField tableName fieldName op (value: obj) sqlProps =
|
||||
Custom.scalar (Query.Exists.byField tableName fieldName op) [ fieldParam value ] toExists sqlProps
|
||||
let byField tableName field sqlProps =
|
||||
Custom.scalar (Query.Exists.byField tableName field) (addFieldParam "@field" field []) toExists sqlProps
|
||||
|
||||
/// Determine if a document exists using a JSON containment query (@>)
|
||||
[<CompiledName "ByContains">]
|
||||
@@ -363,13 +413,14 @@ module WithProps =
|
||||
|
||||
/// Retrieve documents matching a JSON field comparison (->> =)
|
||||
[<CompiledName "FSharpByField">]
|
||||
let byField<'TDoc> tableName fieldName op (value: obj) sqlProps =
|
||||
Custom.list<'TDoc> (Query.Find.byField tableName fieldName op) [ fieldParam value ] fromData<'TDoc> sqlProps
|
||||
let byField<'TDoc> tableName field sqlProps =
|
||||
Custom.list<'TDoc>
|
||||
(Query.Find.byField tableName field) (addFieldParam "@field" field []) fromData<'TDoc> sqlProps
|
||||
|
||||
/// Retrieve documents matching a JSON field comparison (->> =)
|
||||
let ByField<'TDoc>(tableName, fieldName, op, value: obj, sqlProps) =
|
||||
let ByField<'TDoc>(tableName, field, sqlProps) =
|
||||
Custom.List<'TDoc>(
|
||||
Query.Find.byField tableName fieldName op, [ fieldParam value ], fromData<'TDoc>, sqlProps)
|
||||
Query.Find.byField tableName field, addFieldParam "@field" field [], fromData<'TDoc>, sqlProps)
|
||||
|
||||
/// Retrieve documents matching a JSON containment query (@>)
|
||||
[<CompiledName "FSharpByContains">]
|
||||
@@ -395,14 +446,20 @@ module WithProps =
|
||||
|
||||
/// Retrieve the first document matching a JSON field comparison (->> =); returns None if not found
|
||||
[<CompiledName "FSharpFirstByField">]
|
||||
let firstByField<'TDoc> tableName fieldName op (value: obj) sqlProps =
|
||||
let firstByField<'TDoc> tableName field sqlProps =
|
||||
Custom.single<'TDoc>
|
||||
$"{Query.Find.byField tableName fieldName op} LIMIT 1" [ fieldParam value ] fromData<'TDoc> sqlProps
|
||||
$"{Query.Find.byField tableName field} LIMIT 1"
|
||||
(addFieldParam "@field" field [])
|
||||
fromData<'TDoc>
|
||||
sqlProps
|
||||
|
||||
/// Retrieve the first document matching a JSON field comparison (->> =); returns null if not found
|
||||
let FirstByField<'TDoc when 'TDoc: null>(tableName, fieldName, op, value: obj, sqlProps) =
|
||||
let FirstByField<'TDoc when 'TDoc: null>(tableName, field, sqlProps) =
|
||||
Custom.Single<'TDoc>(
|
||||
$"{Query.Find.byField tableName fieldName op} LIMIT 1", [ fieldParam value ], fromData<'TDoc>, sqlProps)
|
||||
$"{Query.Find.byField tableName field} LIMIT 1",
|
||||
addFieldParam "@field" field [],
|
||||
fromData<'TDoc>,
|
||||
sqlProps)
|
||||
|
||||
/// Retrieve the first document matching a JSON containment query (@>); returns None if not found
|
||||
[<CompiledName "FSharpFirstByContains">]
|
||||
@@ -461,9 +518,11 @@ module WithProps =
|
||||
|
||||
/// Patch documents using a JSON field comparison query in the WHERE clause (->> =)
|
||||
[<CompiledName "ByField">]
|
||||
let byField tableName fieldName op (value: obj) (patch: 'TPatch) sqlProps =
|
||||
let byField tableName field (patch: 'TPatch) sqlProps =
|
||||
Custom.nonQuery
|
||||
(Query.Patch.byField tableName fieldName op) [ jsonParam "@data" patch; fieldParam value ] sqlProps
|
||||
(Query.Patch.byField tableName field)
|
||||
(addFieldParam "@field" field [ jsonParam "@data" patch ])
|
||||
sqlProps
|
||||
|
||||
/// Patch documents using a JSON containment query in the WHERE clause (@>)
|
||||
[<CompiledName "ByContains">]
|
||||
@@ -477,6 +536,55 @@ module WithProps =
|
||||
Custom.nonQuery
|
||||
(Query.Patch.byJsonPath tableName) [ jsonParam "@data" patch; "@path", Sql.string jsonPath ] sqlProps
|
||||
|
||||
/// Commands to remove fields from documents
|
||||
[<RequireQualifiedAccess>]
|
||||
module RemoveFields =
|
||||
|
||||
/// Remove fields from a document by the document's ID
|
||||
[<CompiledName "FSharpById">]
|
||||
let byId tableName (docId: 'TKey) fieldNames sqlProps =
|
||||
Custom.nonQuery (Query.RemoveFields.byId tableName) [ idParam docId; fieldNameParam fieldNames ] sqlProps
|
||||
|
||||
/// Remove fields from a document by the document's ID
|
||||
let ById(tableName, docId: 'TKey, fieldNames, sqlProps) =
|
||||
byId tableName docId (List.ofSeq fieldNames) sqlProps
|
||||
|
||||
/// Remove fields from documents via a comparison on a JSON field in the document
|
||||
[<CompiledName "FSharpByField">]
|
||||
let byField tableName field fieldNames sqlProps =
|
||||
Custom.nonQuery
|
||||
(Query.RemoveFields.byField tableName field)
|
||||
(addFieldParam "@field" field [ fieldNameParam fieldNames ])
|
||||
sqlProps
|
||||
|
||||
/// Remove fields from documents via a comparison on a JSON field in the document
|
||||
let ByField(tableName, field, fieldNames, sqlProps) =
|
||||
byField tableName field (List.ofSeq fieldNames) sqlProps
|
||||
|
||||
/// Remove fields from documents via a JSON containment query (@>)
|
||||
[<CompiledName "FSharpByContains">]
|
||||
let byContains tableName (criteria: 'TContains) fieldNames sqlProps =
|
||||
Custom.nonQuery
|
||||
(Query.RemoveFields.byContains tableName)
|
||||
[ jsonParam "@criteria" criteria; fieldNameParam fieldNames ]
|
||||
sqlProps
|
||||
|
||||
/// Remove fields from documents via a JSON containment query (@>)
|
||||
let ByContains(tableName, criteria: 'TContains, fieldNames, sqlProps) =
|
||||
byContains tableName criteria (List.ofSeq fieldNames) sqlProps
|
||||
|
||||
/// Remove fields from documents via a JSON Path match query (@?)
|
||||
[<CompiledName "FSharpByJsonPath">]
|
||||
let byJsonPath tableName jsonPath fieldNames sqlProps =
|
||||
Custom.nonQuery
|
||||
(Query.RemoveFields.byJsonPath tableName)
|
||||
[ "@path", Sql.string jsonPath; fieldNameParam fieldNames ]
|
||||
sqlProps
|
||||
|
||||
/// Remove fields from documents via a JSON Path match query (@?)
|
||||
let ByJsonPath(tableName, jsonPath, fieldNames, sqlProps) =
|
||||
byJsonPath tableName jsonPath (List.ofSeq fieldNames) sqlProps
|
||||
|
||||
/// Commands to delete documents
|
||||
[<RequireQualifiedAccess>]
|
||||
module Delete =
|
||||
@@ -488,8 +596,8 @@ module WithProps =
|
||||
|
||||
/// Delete documents by matching a JSON field comparison query (->> =)
|
||||
[<CompiledName "ByField">]
|
||||
let byField tableName fieldName op (value: obj) sqlProps =
|
||||
Custom.nonQuery (Query.Delete.byField tableName fieldName op) [ fieldParam value ] sqlProps
|
||||
let byField tableName field sqlProps =
|
||||
Custom.nonQuery (Query.Delete.byField tableName field) (addFieldParam "@field" field []) sqlProps
|
||||
|
||||
/// Delete documents by matching a JSON contains query (@>)
|
||||
[<CompiledName "ByContains">]
|
||||
@@ -585,8 +693,8 @@ module Count =
|
||||
|
||||
/// Count matching documents using a JSON field comparison query (->> =)
|
||||
[<CompiledName "ByField">]
|
||||
let byField tableName fieldName op (value: obj) =
|
||||
WithProps.Count.byField tableName fieldName op value (fromDataSource ())
|
||||
let byField tableName field =
|
||||
WithProps.Count.byField tableName field (fromDataSource ())
|
||||
|
||||
/// Count matching documents using a JSON containment query (@>)
|
||||
[<CompiledName "ByContains">]
|
||||
@@ -610,8 +718,8 @@ module Exists =
|
||||
|
||||
/// Determine if documents exist using a JSON field comparison query (->> =)
|
||||
[<CompiledName "ByField">]
|
||||
let byField tableName fieldName op (value: obj) =
|
||||
WithProps.Exists.byField tableName fieldName op value (fromDataSource ())
|
||||
let byField tableName field =
|
||||
WithProps.Exists.byField tableName field (fromDataSource ())
|
||||
|
||||
/// Determine if documents exist using a JSON containment query (@>)
|
||||
[<CompiledName "ByContains">]
|
||||
@@ -648,12 +756,12 @@ module Find =
|
||||
|
||||
/// Retrieve documents matching a JSON field comparison query (->> =)
|
||||
[<CompiledName "FSharpByField">]
|
||||
let byField<'TDoc> tableName fieldName op (value: obj) =
|
||||
WithProps.Find.byField<'TDoc> tableName fieldName op value (fromDataSource ())
|
||||
let byField<'TDoc> tableName field =
|
||||
WithProps.Find.byField<'TDoc> tableName field (fromDataSource ())
|
||||
|
||||
/// Retrieve documents matching a JSON field comparison query (->> =)
|
||||
let ByField<'TDoc>(tableName, fieldName, op, value: obj) =
|
||||
WithProps.Find.ByField<'TDoc>(tableName, fieldName, op, value, fromDataSource ())
|
||||
let ByField<'TDoc>(tableName, field) =
|
||||
WithProps.Find.ByField<'TDoc>(tableName, field, fromDataSource ())
|
||||
|
||||
/// Retrieve documents matching a JSON containment query (@>)
|
||||
[<CompiledName "FSharpByContains">]
|
||||
@@ -675,12 +783,12 @@ module Find =
|
||||
|
||||
/// Retrieve the first document matching a JSON field comparison query (->> =); returns None if not found
|
||||
[<CompiledName "FSharpFirstByField">]
|
||||
let firstByField<'TDoc> tableName fieldName op (value: obj) =
|
||||
WithProps.Find.firstByField<'TDoc> tableName fieldName op value (fromDataSource ())
|
||||
let firstByField<'TDoc> tableName field =
|
||||
WithProps.Find.firstByField<'TDoc> tableName field (fromDataSource ())
|
||||
|
||||
/// Retrieve the first document matching a JSON field comparison query (->> =); returns null if not found
|
||||
let FirstByField<'TDoc when 'TDoc: null>(tableName, fieldName, op, value: obj) =
|
||||
WithProps.Find.FirstByField<'TDoc>(tableName, fieldName, op, value, fromDataSource ())
|
||||
let FirstByField<'TDoc when 'TDoc: null>(tableName, field) =
|
||||
WithProps.Find.FirstByField<'TDoc>(tableName, field, fromDataSource ())
|
||||
|
||||
/// Retrieve the first document matching a JSON containment query (@>); returns None if not found
|
||||
[<CompiledName "FSharpFirstByContains">]
|
||||
@@ -731,8 +839,8 @@ module Patch =
|
||||
|
||||
/// Patch documents using a JSON field comparison query in the WHERE clause (->> =)
|
||||
[<CompiledName "ByField">]
|
||||
let byField tableName fieldName op (value: obj) (patch: 'TPatch) =
|
||||
WithProps.Patch.byField tableName fieldName op value patch (fromDataSource ())
|
||||
let byField tableName field (patch: 'TPatch) =
|
||||
WithProps.Patch.byField tableName field patch (fromDataSource ())
|
||||
|
||||
/// Patch documents using a JSON containment query in the WHERE clause (@>)
|
||||
[<CompiledName "ByContains">]
|
||||
@@ -745,6 +853,47 @@ module Patch =
|
||||
WithProps.Patch.byJsonPath tableName jsonPath patch (fromDataSource ())
|
||||
|
||||
|
||||
/// Commands to remove fields from documents
|
||||
[<RequireQualifiedAccess>]
|
||||
module RemoveFields =
|
||||
|
||||
/// Remove fields from a document by the document's ID
|
||||
[<CompiledName "FSharpById">]
|
||||
let byId tableName (docId: 'TKey) fieldNames =
|
||||
WithProps.RemoveFields.byId tableName docId fieldNames (fromDataSource ())
|
||||
|
||||
/// Remove fields from a document by the document's ID
|
||||
let ById(tableName, docId: 'TKey, fieldNames) =
|
||||
WithProps.RemoveFields.ById(tableName, docId, fieldNames, fromDataSource ())
|
||||
|
||||
/// Remove fields from documents via a comparison on a JSON field in the document
|
||||
[<CompiledName "FSharpByField">]
|
||||
let byField tableName field fieldNames =
|
||||
WithProps.RemoveFields.byField tableName field fieldNames (fromDataSource ())
|
||||
|
||||
/// Remove fields from documents via a comparison on a JSON field in the document
|
||||
let ByField(tableName, field, fieldNames) =
|
||||
WithProps.RemoveFields.ByField(tableName, field, fieldNames, fromDataSource ())
|
||||
|
||||
/// Remove fields from documents via a JSON containment query (@>)
|
||||
[<CompiledName "FSharpByContains">]
|
||||
let byContains tableName (criteria: 'TContains) fieldNames =
|
||||
WithProps.RemoveFields.byContains tableName criteria fieldNames (fromDataSource ())
|
||||
|
||||
/// Remove fields from documents via a JSON containment query (@>)
|
||||
let ByContains(tableName, criteria: 'TContains, fieldNames) =
|
||||
WithProps.RemoveFields.ByContains(tableName, criteria, fieldNames, fromDataSource ())
|
||||
|
||||
/// Remove fields from documents via a JSON Path match query (@?)
|
||||
[<CompiledName "FSharpByJsonPath">]
|
||||
let byJsonPath tableName jsonPath fieldNames =
|
||||
WithProps.RemoveFields.byJsonPath tableName jsonPath fieldNames (fromDataSource ())
|
||||
|
||||
/// Remove fields from documents via a JSON Path match query (@?)
|
||||
let ByJsonPath(tableName, jsonPath, fieldNames) =
|
||||
WithProps.RemoveFields.ByJsonPath(tableName, jsonPath, fieldNames, fromDataSource ())
|
||||
|
||||
|
||||
/// Commands to delete documents
|
||||
[<RequireQualifiedAccess>]
|
||||
module Delete =
|
||||
@@ -756,8 +905,8 @@ module Delete =
|
||||
|
||||
/// Delete documents by matching a JSON field comparison query (->> =)
|
||||
[<CompiledName "ByField">]
|
||||
let byField tableName fieldName op (value: obj) =
|
||||
WithProps.Delete.byField tableName fieldName op value (fromDataSource ())
|
||||
let byField tableName field =
|
||||
WithProps.Delete.byField tableName field (fromDataSource ())
|
||||
|
||||
/// Delete documents by matching a JSON containment query (@>)
|
||||
[<CompiledName "ByContains">]
|
||||
|
||||
Reference in New Issue
Block a user