|
|
|
|
@@ -4,7 +4,7 @@ open Npgsql
|
|
|
|
|
open Npgsql.FSharp
|
|
|
|
|
open WithProps
|
|
|
|
|
|
|
|
|
|
/// F# Extensions for the NpgsqlConnection type
|
|
|
|
|
/// <summary>F# Extensions for the NpgsqlConnection type</summary>
|
|
|
|
|
[<AutoOpen>]
|
|
|
|
|
module Extensions =
|
|
|
|
|
|
|
|
|
|
@@ -377,247 +377,455 @@ module Extensions =
|
|
|
|
|
|
|
|
|
|
open System.Runtime.CompilerServices
|
|
|
|
|
|
|
|
|
|
/// C# extensions on the NpgsqlConnection type
|
|
|
|
|
/// <summary>C# extensions on the NpgsqlConnection type</summary>
|
|
|
|
|
type NpgsqlConnectionCSharpExtensions =
|
|
|
|
|
|
|
|
|
|
/// Execute a query that returns a list of results
|
|
|
|
|
/// <summary>Execute a query that returns a list of results</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="query">The query to retrieve the results</param>
|
|
|
|
|
/// <param name="parameters">Parameters to use for the query</param>
|
|
|
|
|
/// <param name="mapFunc">The mapping function between the document and the domain item</param>
|
|
|
|
|
/// <returns>A list of results for the given query</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline CustomList<'TDoc>(conn, query, parameters, mapFunc: System.Func<RowReader, 'TDoc>) =
|
|
|
|
|
Custom.List<'TDoc>(query, parameters, mapFunc, Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Execute a query that returns one or no results; returns None if not found
|
|
|
|
|
/// <summary>Execute a query that returns one or no results</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="query">The query to retrieve the results</param>
|
|
|
|
|
/// <param name="parameters">Parameters to use for the query</param>
|
|
|
|
|
/// <param name="mapFunc">The mapping function between the document and the domain item</param>
|
|
|
|
|
/// <returns>The first matching result, or <tt>null</tt> if not found</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline CustomSingle<'TDoc when 'TDoc: null and 'TDoc: not struct>(
|
|
|
|
|
conn, query, parameters, mapFunc: System.Func<RowReader, 'TDoc>) =
|
|
|
|
|
Custom.Single<'TDoc>(query, parameters, mapFunc, Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Execute a query that returns no results
|
|
|
|
|
/// <summary>Execute a query that returns no results</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="query">The query to retrieve the results</param>
|
|
|
|
|
/// <param name="parameters">Parameters to use for the query</param>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline CustomNonQuery(conn, query, parameters) =
|
|
|
|
|
Custom.nonQuery query parameters (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Execute a query that returns a scalar value
|
|
|
|
|
/// <summary>Execute a query that returns a scalar value</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="query">The query to retrieve the value</param>
|
|
|
|
|
/// <param name="parameters">Parameters to use for the query</param>
|
|
|
|
|
/// <param name="mapFunc">The mapping function to obtain the value</param>
|
|
|
|
|
/// <returns>The scalar value for the query</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline CustomScalar<'T when 'T: struct>(
|
|
|
|
|
conn, query, parameters, mapFunc: System.Func<RowReader, 'T>) =
|
|
|
|
|
Custom.Scalar(query, parameters, mapFunc, Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Create a document table
|
|
|
|
|
/// <summary>Create a document table</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="name">The table whose existence should be ensured (may include schema)</param>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline EnsureTable(conn, name) =
|
|
|
|
|
Definition.ensureTable name (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Create an index on documents in the specified table
|
|
|
|
|
/// <summary>Create an index on documents in the specified table</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="name">The table to be indexed (may include schema)</param>
|
|
|
|
|
/// <param name="idxType">The type of document index to create</param>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline EnsureDocumentIndex(conn, name, idxType) =
|
|
|
|
|
Definition.ensureDocumentIndex name idxType (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Create an index on field(s) within documents in the specified table
|
|
|
|
|
/// <summary>Create an index on field(s) within documents in the specified table</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table to be indexed (may include schema)</param>
|
|
|
|
|
/// <param name="indexName">The name of the index to create</param>
|
|
|
|
|
/// <param name="fields">One or more fields to be indexed</param>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline EnsureFieldIndex(conn, tableName, indexName, fields) =
|
|
|
|
|
Definition.ensureFieldIndex tableName indexName fields (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Insert a new document
|
|
|
|
|
/// <summary>Insert a new document</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table into which the document should be inserted (may include schema)</param>
|
|
|
|
|
/// <param name="document">The document to be inserted</param>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline Insert<'TDoc>(conn, tableName, document: 'TDoc) =
|
|
|
|
|
insert<'TDoc> tableName document (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Save a document, inserting it if it does not exist and updating it if it does (AKA "upsert")
|
|
|
|
|
/// <summary>Save a document, inserting it if it does not exist and updating it if it does (AKA "upsert")</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table into which the document should be saved (may include schema)</param>
|
|
|
|
|
/// <param name="document">The document to be saved</param>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline Save<'TDoc>(conn, tableName, document: 'TDoc) =
|
|
|
|
|
save<'TDoc> tableName document (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Count all documents in a table
|
|
|
|
|
/// <summary>Count all documents in a table</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table in which documents should be counted (may include schema)</param>
|
|
|
|
|
/// <returns>The count of the documents in the table</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline CountAll(conn, tableName) =
|
|
|
|
|
Count.all tableName (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Count matching documents using a JSON field comparison query (->> =)
|
|
|
|
|
/// <summary>Count matching documents using JSON field comparisons (<tt>->> =</tt>, etc.)</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table in which documents should be counted (may include schema)</param>
|
|
|
|
|
/// <param name="howMatched">Whether to match any or all of the field conditions</param>
|
|
|
|
|
/// <param name="fields">The field conditions to match</param>
|
|
|
|
|
/// <returns>The count of matching documents in the table</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline CountByFields(conn, tableName, howMatched, fields) =
|
|
|
|
|
Count.byFields tableName howMatched fields (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Count matching documents using a JSON containment query (@>)
|
|
|
|
|
/// <summary>Count matching documents using a JSON containment query (<tt>@></tt>)</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table in which documents should be counted (may include schema)</param>
|
|
|
|
|
/// <param name="criteria">The document to match with the containment query</param>
|
|
|
|
|
/// <returns>The count of the documents in the table</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline CountByContains(conn, tableName, criteria: 'TCriteria) =
|
|
|
|
|
Count.byContains tableName criteria (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Count matching documents using a JSON Path match query (@?)
|
|
|
|
|
/// <summary>Count matching documents using a JSON Path match query (<tt>@?</tt>)</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table in which documents should be counted (may include schema)</param>
|
|
|
|
|
/// <param name="jsonPath">The JSON Path expression to be matched</param>
|
|
|
|
|
/// <returns>The count of the documents in the table</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline CountByJsonPath(conn, tableName, jsonPath) =
|
|
|
|
|
Count.byJsonPath tableName jsonPath (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Determine if a document exists for the given ID
|
|
|
|
|
/// <summary>Determine if a document exists for the given ID</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table in which existence should be checked (may include schema)</param>
|
|
|
|
|
/// <param name="docId">The ID of the document whose existence should be checked</param>
|
|
|
|
|
/// <returns>True if a document exists, false if not</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline ExistsById(conn, tableName, docId) =
|
|
|
|
|
Exists.byId tableName docId (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Determine if documents exist using a JSON field comparison query (->> =)
|
|
|
|
|
/// <summary>Determine if a document exists using JSON field comparisons (<tt>->> =</tt>, etc.)</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table in which existence should be checked (may include schema)</param>
|
|
|
|
|
/// <param name="howMatched">Whether to match any or all of the field conditions</param>
|
|
|
|
|
/// <param name="fields">The field conditions to match</param>
|
|
|
|
|
/// <returns>True if any matching documents exist, false if not</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline ExistsByFields(conn, tableName, howMatched, fields) =
|
|
|
|
|
Exists.byFields tableName howMatched fields (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Determine if documents exist using a JSON containment query (@>)
|
|
|
|
|
/// <summary>Determine if a document exists using a JSON containment query (<tt>@></tt>)</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table in which existence should be checked (may include schema)</param>
|
|
|
|
|
/// <param name="criteria">The document to match with the containment query</param>
|
|
|
|
|
/// <returns>True if any matching documents exist, false if not</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline ExistsByContains(conn, tableName, criteria: 'TCriteria) =
|
|
|
|
|
Exists.byContains tableName criteria (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Determine if documents exist using a JSON Path match query (@?)
|
|
|
|
|
/// <summary>Determine if a document exists using a JSON Path match query (<tt>@?</tt>)</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table in which existence should be checked (may include schema)</param>
|
|
|
|
|
/// <param name="jsonPath">The JSON Path expression to be matched</param>
|
|
|
|
|
/// <returns>True if any matching documents exist, false if not</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline ExistsByJsonPath(conn, tableName, jsonPath) =
|
|
|
|
|
Exists.byJsonPath tableName jsonPath (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Retrieve all documents in the given table
|
|
|
|
|
/// <summary>Retrieve all documents in the given table</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table from which documents should be retrieved (may include schema)</param>
|
|
|
|
|
/// <returns>All documents from the given table</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline FindAll<'TDoc>(conn, tableName) =
|
|
|
|
|
Find.All<'TDoc>(tableName, Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Retrieve all documents in the given table ordered by the given fields in the document
|
|
|
|
|
/// <summary>Retrieve all documents in the given table ordered by the given fields in the document</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table from which documents should be retrieved (may include schema)</param>
|
|
|
|
|
/// <param name="orderFields">Fields by which the results should be ordered</param>
|
|
|
|
|
/// <returns>All documents from the given table, ordered by the given fields</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline FindAllOrdered<'TDoc>(conn, tableName, orderFields) =
|
|
|
|
|
Find.AllOrdered<'TDoc>(tableName, orderFields, Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Retrieve a document by its ID; returns None if not found
|
|
|
|
|
/// <summary>Retrieve a document by its ID</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table from which a document should be retrieved (may include schema)</param>
|
|
|
|
|
/// <param name="docId">The ID of the document to retrieve</param>
|
|
|
|
|
/// <returns>The document if found, <tt>null</tt> otherwise</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline FindById<'TKey, 'TDoc when 'TDoc: null and 'TDoc: not struct>(conn, tableName, docId: 'TKey) =
|
|
|
|
|
Find.ById<'TKey, 'TDoc>(tableName, docId, Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Retrieve documents matching a JSON field comparison query (->> =)
|
|
|
|
|
/// <summary>Retrieve documents matching JSON field comparisons (<tt>->> =</tt>, etc.)</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table from which documents should be retrieved (may include schema)</param>
|
|
|
|
|
/// <param name="howMatched">Whether to match any or all of the field conditions</param>
|
|
|
|
|
/// <param name="fields">The field conditions to match</param>
|
|
|
|
|
/// <returns>All documents matching the given fields</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline FindByFields<'TDoc>(conn, tableName, howMatched, fields) =
|
|
|
|
|
Find.ByFields<'TDoc>(tableName, howMatched, fields, Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Retrieve documents matching a JSON field comparison query (->> =) ordered by the given fields in the document
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Retrieve documents matching JSON field comparisons (<tt>->> =</tt>, etc.) ordered by the given fields in
|
|
|
|
|
/// the document
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table from which documents should be retrieved (may include schema)</param>
|
|
|
|
|
/// <param name="howMatched">Whether to match any or all of the field conditions</param>
|
|
|
|
|
/// <param name="queryFields">The field conditions to match</param>
|
|
|
|
|
/// <param name="orderFields">Fields by which the results should be ordered</param>
|
|
|
|
|
/// <returns>All documents matching the given fields, ordered by the other given fields</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline FindByFieldsOrdered<'TDoc>(conn, tableName, howMatched, queryFields, orderFields) =
|
|
|
|
|
Find.ByFieldsOrdered<'TDoc>(
|
|
|
|
|
tableName, howMatched, queryFields, orderFields, Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Retrieve documents matching a JSON containment query (@>)
|
|
|
|
|
/// <summary>Retrieve documents matching a JSON containment query (<tt>@></tt>)</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table from which documents should be retrieved (may include schema)</param>
|
|
|
|
|
/// <param name="criteria">The document to match with the containment query</param>
|
|
|
|
|
/// <returns>All documents matching the given containment query</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline FindByContains<'TDoc>(conn, tableName, criteria: obj) =
|
|
|
|
|
Find.ByContains<'TDoc>(tableName, criteria, Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Retrieve documents matching a JSON containment query (@>) ordered by the given fields in the document
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Retrieve documents matching a JSON containment query (<tt>@></tt>) ordered by the given fields in the
|
|
|
|
|
/// document
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table from which documents should be retrieved (may include schema)</param>
|
|
|
|
|
/// <param name="criteria">The document to match with the containment query</param>
|
|
|
|
|
/// <param name="orderFields">Fields by which the results should be ordered</param>
|
|
|
|
|
/// <returns>All documents matching the given containment query, ordered by the given fields</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline FindByContainsOrdered<'TDoc>(conn, tableName, criteria: obj, orderFields) =
|
|
|
|
|
Find.ByContainsOrdered<'TDoc>(tableName, criteria, orderFields, Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Retrieve documents matching a JSON Path match query (@?)
|
|
|
|
|
/// <summary>Retrieve documents matching a JSON Path match query (<tt>@?</tt>)</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table from which documents should be retrieved (may include schema)</param>
|
|
|
|
|
/// <param name="jsonPath">The JSON Path expression to match</param>
|
|
|
|
|
/// <returns>All documents matching the given JSON Path expression</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline FindByJsonPath<'TDoc>(conn, tableName, jsonPath) =
|
|
|
|
|
Find.ByJsonPath<'TDoc>(tableName, jsonPath, Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Retrieve documents matching a JSON Path match query (@?) ordered by the given fields in the document
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Retrieve documents matching a JSON Path match query (<tt>@?</tt>) ordered by the given fields in the document
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table from which documents should be retrieved (may include schema)</param>
|
|
|
|
|
/// <param name="jsonPath">The JSON Path expression to match</param>
|
|
|
|
|
/// <param name="orderFields">Fields by which the results should be ordered</param>
|
|
|
|
|
/// <returns>All documents matching the given JSON Path expression, ordered by the given fields</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline FindByJsonPathOrdered<'TDoc>(conn, tableName, jsonPath, orderFields) =
|
|
|
|
|
Find.ByJsonPathOrdered<'TDoc>(tableName, jsonPath, orderFields, Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Retrieve the first document matching a JSON field comparison query (->> =); returns null if not found
|
|
|
|
|
/// <summary>Retrieve the first document matching JSON field comparisons (<tt>->> =</tt>, etc.)</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table from which a document should be retrieved (may include schema)</param>
|
|
|
|
|
/// <param name="howMatched">Whether to match any or all of the field conditions</param>
|
|
|
|
|
/// <param name="fields">The field conditions to match</param>
|
|
|
|
|
/// <returns>The first document, or <tt>null</tt> if not found</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline FindFirstByFields<'TDoc when 'TDoc: null and 'TDoc: not struct>(
|
|
|
|
|
conn, tableName, howMatched, fields) =
|
|
|
|
|
Find.FirstByFields<'TDoc>(tableName, howMatched, fields, Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Retrieve the first document matching a JSON field comparison query (->> =) ordered by the given fields in the
|
|
|
|
|
/// document; returns null if not found
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Retrieve the first document matching JSON field comparisons (<tt>->> =</tt>, etc.) ordered by the given
|
|
|
|
|
/// fields in the document
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table from which a document should be retrieved (may include schema)</param>
|
|
|
|
|
/// <param name="howMatched">Whether to match any or all of the field conditions</param>
|
|
|
|
|
/// <param name="queryFields">The field conditions to match</param>
|
|
|
|
|
/// <param name="orderFields">Fields by which the results should be ordered</param>
|
|
|
|
|
/// <returns>The first document ordered by the given fields, or <tt>null</tt> if not found</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline FindFirstByFieldsOrdered<'TDoc when 'TDoc: null and 'TDoc: not struct>(
|
|
|
|
|
conn, tableName, howMatched, queryFields, orderFields) =
|
|
|
|
|
Find.FirstByFieldsOrdered<'TDoc>(
|
|
|
|
|
tableName, howMatched, queryFields, orderFields, Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Retrieve the first document matching a JSON containment query (@>); returns None if not found
|
|
|
|
|
/// <summary>Retrieve the first document matching a JSON containment query (<tt>@></tt>)</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table from which a document should be retrieved (may include schema)</param>
|
|
|
|
|
/// <param name="criteria">The document to match with the containment query</param>
|
|
|
|
|
/// <returns>The first document, or <tt>null</tt> if not found</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline FindFirstByContains<'TDoc when 'TDoc: null and 'TDoc: not struct>(
|
|
|
|
|
conn, tableName, criteria: obj) =
|
|
|
|
|
Find.FirstByContains<'TDoc>(tableName, criteria, Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Retrieve the first document matching a JSON containment query (@>) ordered by the given fields in the document;
|
|
|
|
|
/// returns None if not found
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Retrieve the first document matching a JSON containment query (<tt>@></tt>) ordered by the given fields in
|
|
|
|
|
/// the document
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table from which a document should be retrieved (may include schema)</param>
|
|
|
|
|
/// <param name="criteria">The document to match with the containment query</param>
|
|
|
|
|
/// <param name="orderFields">Fields by which the results should be ordered</param>
|
|
|
|
|
/// <returns>The first document ordered by the given fields, or <tt>null</tt> if not found</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline FindFirstByContainsOrdered<'TDoc when 'TDoc: null and 'TDoc: not struct>(
|
|
|
|
|
conn, tableName, criteria: obj, orderFields) =
|
|
|
|
|
Find.FirstByContainsOrdered<'TDoc>(tableName, criteria, orderFields, Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Retrieve the first document matching a JSON Path match query (@?); returns None if not found
|
|
|
|
|
/// <summary>Retrieve the first document matching a JSON Path match query (<tt>@?</tt>)</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table from which a document should be retrieved (may include schema)</param>
|
|
|
|
|
/// <param name="jsonPath">The JSON Path expression to match</param>
|
|
|
|
|
/// <returns>The first document, or <tt>null</tt> if not found</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline FindFirstByJsonPath<'TDoc when 'TDoc: null and 'TDoc: not struct>(conn, tableName, jsonPath) =
|
|
|
|
|
Find.FirstByJsonPath<'TDoc>(tableName, jsonPath, Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Retrieve the first document matching a JSON Path match query (@?) ordered by the given fields in the document;
|
|
|
|
|
/// returns None if not found
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Retrieve the first document matching a JSON Path match query (<tt>@?</tt>) ordered by the given fields in the
|
|
|
|
|
/// document
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table from which a document should be retrieved (may include schema)</param>
|
|
|
|
|
/// <param name="jsonPath">The JSON Path expression to match</param>
|
|
|
|
|
/// <param name="orderFields">Fields by which the results should be ordered</param>
|
|
|
|
|
/// <returns>The first document ordered by the given fields, or <tt>null</tt> if not found</returns>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline FindFirstByJsonPathOrdered<'TDoc when 'TDoc: null and 'TDoc: not struct>(
|
|
|
|
|
conn, tableName, jsonPath, orderFields) =
|
|
|
|
|
Find.FirstByJsonPathOrdered<'TDoc>(tableName, jsonPath, orderFields, Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Update an entire document by its ID
|
|
|
|
|
/// <summary>Update (replace) an entire document by its ID</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table in which a document should be updated (may include schema)</param>
|
|
|
|
|
/// <param name="docId">The ID of the document to be updated (replaced)</param>
|
|
|
|
|
/// <param name="document">The new document</param>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline UpdateById(conn, tableName, docId: 'TKey, document: 'TDoc) =
|
|
|
|
|
Update.byId tableName docId document (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Update an entire document by its ID, using the provided function to obtain the ID from the document
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Update (replace) an entire document by its ID, using the provided function to obtain the ID from the document
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table in which a document should be updated (may include schema)</param>
|
|
|
|
|
/// <param name="idFunc">The function to obtain the ID of the document</param>
|
|
|
|
|
/// <param name="document">The new document</param>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline UpdateByFunc(conn, tableName, idFunc: System.Func<'TDoc, 'TKey>, document: 'TDoc) =
|
|
|
|
|
Update.ByFunc(tableName, idFunc, document, Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Patch a document by its ID
|
|
|
|
|
/// <summary>Patch a document by its ID</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table in which a document should be patched (may include schema)</param>
|
|
|
|
|
/// <param name="docId">The ID of the document to patch</param>
|
|
|
|
|
/// <param name="patch">The partial document to patch the existing document</param>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline PatchById(conn, tableName, docId: 'TKey, patch: 'TPatch) =
|
|
|
|
|
Patch.byId tableName docId patch (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Patch documents using a JSON field comparison query in the WHERE clause (->> =)
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Patch documents using a JSON field comparison query in the <tt>WHERE</tt> clause (<tt>->> =</tt>, etc.)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table in which documents should be patched (may include schema)</param>
|
|
|
|
|
/// <param name="howMatched">Whether to match any or all of the field conditions</param>
|
|
|
|
|
/// <param name="fields">The field conditions to match</param>
|
|
|
|
|
/// <param name="patch">The partial document to patch the existing document</param>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline PatchByFields(conn, tableName, howMatched, fields, patch: 'TPatch) =
|
|
|
|
|
Patch.byFields tableName howMatched fields patch (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Patch documents using a JSON containment query in the WHERE clause (@>)
|
|
|
|
|
/// <summary>Patch documents using a JSON containment query in the <tt>WHERE</tt> clause (<tt>@></tt>)</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table in which documents should be patched (may include schema)</param>
|
|
|
|
|
/// <param name="criteria">The document to match the containment query</param>
|
|
|
|
|
/// <param name="patch">The partial document to patch the existing document</param>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline PatchByContains(conn, tableName, criteria: 'TCriteria, patch: 'TPatch) =
|
|
|
|
|
Patch.byContains tableName criteria patch (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Patch documents using a JSON Path match query in the WHERE clause (@?)
|
|
|
|
|
/// <summary>Patch documents using a JSON Path match query in the <tt>WHERE</tt> clause (<tt>@?</tt>)</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table in which documents should be patched (may include schema)</param>
|
|
|
|
|
/// <param name="jsonPath">The JSON Path expression to match</param>
|
|
|
|
|
/// <param name="patch">The partial document to patch the existing document</param>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline PatchByJsonPath(conn, tableName, jsonPath, patch: 'TPatch) =
|
|
|
|
|
Patch.byJsonPath tableName jsonPath patch (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Remove fields from a document by the document's ID
|
|
|
|
|
/// <summary>Remove fields from a document by the document's ID</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table in which a document should be modified (may include schema)</param>
|
|
|
|
|
/// <param name="docId">The ID of the document to modify</param>
|
|
|
|
|
/// <param name="fieldNames">One or more field names to remove from the document</param>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline RemoveFieldsById(conn, tableName, docId: 'TKey, fieldNames) =
|
|
|
|
|
RemoveFields.byId tableName docId fieldNames (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Remove fields from documents via a comparison on JSON fields in the document
|
|
|
|
|
/// <summary>Remove fields from documents via a comparison on JSON fields in the document</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table in which documents should be modified (may include schema)</param>
|
|
|
|
|
/// <param name="howMatched">Whether to match any or all of the field conditions</param>
|
|
|
|
|
/// <param name="fields">The field conditions to match</param>
|
|
|
|
|
/// <param name="fieldNames">One or more field names to remove from the matching documents</param>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline RemoveFieldsByFields(conn, tableName, howMatched, fields, fieldNames) =
|
|
|
|
|
RemoveFields.byFields tableName howMatched fields fieldNames (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Remove fields from documents via a JSON containment query (@>)
|
|
|
|
|
/// <summary>Remove fields from documents via a JSON containment query (<tt>@></tt>)</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table in which documents should be modified (may include schema)</param>
|
|
|
|
|
/// <param name="criteria">The document to match the containment query</param>
|
|
|
|
|
/// <param name="fieldNames">One or more field names to remove from the matching documents</param>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline RemoveFieldsByContains(conn, tableName, criteria: 'TContains, fieldNames) =
|
|
|
|
|
RemoveFields.byContains tableName criteria fieldNames (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Remove fields from documents via a JSON Path match query (@?)
|
|
|
|
|
/// <summary>Remove fields from documents via a JSON Path match query (<tt>@?</tt>)</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table in which documents should be modified (may include schema)</param>
|
|
|
|
|
/// <param name="jsonPath">The JSON Path expression to match</param>
|
|
|
|
|
/// <param name="fieldNames">One or more field names to remove from the matching documents</param>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline RemoveFieldsByJsonPath(conn, tableName, jsonPath, fieldNames) =
|
|
|
|
|
RemoveFields.byJsonPath tableName jsonPath fieldNames (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Delete a document by its ID
|
|
|
|
|
/// <summary>Delete a document by its ID</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table in which a document should be deleted (may include schema)</param>
|
|
|
|
|
/// <param name="docId">The ID of the document to delete</param>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline DeleteById(conn, tableName, docId: 'TKey) =
|
|
|
|
|
Delete.byId tableName docId (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Delete documents by matching a JSON field comparison query (->> =)
|
|
|
|
|
/// <summary>Delete documents by matching a JSON field comparison query (<tt>->> =</tt>, etc.)</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table in which documents should be deleted (may include schema)</param>
|
|
|
|
|
/// <param name="howMatched">Whether to match any or all of the field conditions</param>
|
|
|
|
|
/// <param name="fields">The field conditions to match</param>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline DeleteByFields(conn, tableName, howMatched, fields) =
|
|
|
|
|
Delete.byFields tableName howMatched fields (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Delete documents by matching a JSON containment query (@>)
|
|
|
|
|
/// <summary>Delete documents by matching a JSON contains query (<tt>@></tt>)</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table in which documents should be deleted (may include schema)</param>
|
|
|
|
|
/// <param name="criteria">The document to match the containment query</param>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline DeleteByContains(conn, tableName, criteria: 'TContains) =
|
|
|
|
|
Delete.byContains tableName criteria (Sql.existingConnection conn)
|
|
|
|
|
|
|
|
|
|
/// Delete documents by matching a JSON Path match query (@?)
|
|
|
|
|
/// <summary>Delete documents by matching a JSON Path match query (@?)</summary>
|
|
|
|
|
/// <param name="conn">The <tt>NpgsqlConnection</tt> on which to run the query</param>
|
|
|
|
|
/// <param name="tableName">The table in which documents should be deleted (may include schema)</param>
|
|
|
|
|
/// <param name="jsonPath">The JSON Path expression to match</param>
|
|
|
|
|
[<Extension>]
|
|
|
|
|
static member inline DeleteByJsonPath(conn, tableName, path) =
|
|
|
|
|
Delete.byJsonPath tableName path (Sql.existingConnection conn)
|
|
|
|
|
static member inline DeleteByJsonPath(conn, tableName, jsonPath) =
|
|
|
|
|
Delete.byJsonPath tableName jsonPath (Sql.existingConnection conn)
|
|
|
|
|
|