diff --git a/src/Postgres/Extensions.fs b/src/Postgres/Extensions.fs
index 568b51b..e53536c 100644
--- a/src/Postgres/Extensions.fs
+++ b/src/Postgres/Extensions.fs
@@ -18,6 +18,22 @@ module Extensions =
member conn.customList<'TDoc> query parameters (mapFunc: RowReader -> 'TDoc) =
Custom.list<'TDoc> query parameters mapFunc (Sql.existingConnection conn)
+ /// Execute a query that returns a JSON array of results
+ /// The query to retrieve the results
+ /// Parameters to use for the query
+ /// The mapping function to extract the document
+ /// A JSON array of results for the given query
+ member conn.customJsonArray query parameters mapFunc =
+ Custom.jsonArray query parameters mapFunc (Sql.existingConnection conn)
+
+ /// Execute a query, writing its results to the given StreamWriter
+ /// The query to retrieve the results
+ /// Parameters to use for the query
+ /// The StreamWriter to which the results should be written
+ /// The mapping function to extract the document
+ member conn.writeCustomJsonArray query parameters writer mapFunc =
+ Custom.writeJsonArray query parameters writer mapFunc (Sql.existingConnection conn)
+
/// Execute a query that returns one or no results
/// The query to retrieve the results
/// Parameters to use for the query
@@ -26,6 +42,14 @@ module Extensions =
member conn.customSingle<'TDoc> query parameters (mapFunc: RowReader -> 'TDoc) =
Custom.single<'TDoc> query parameters mapFunc (Sql.existingConnection conn)
+ /// Execute a query that returns one or no JSON documents
+ /// The query to retrieve the results
+ /// Parameters to use for the query
+ /// The mapping function to extract the document
+ /// The JSON document with the first matching result, or an empty document if not found
+ member conn.customJsonSingle query parameters mapFunc =
+ Custom.jsonSingle query parameters mapFunc (Sql.existingConnection conn)
+
/// Execute a query that returns no results
/// The query to retrieve the results
/// Parameters to use for the query
@@ -269,6 +293,293 @@ module Extensions =
member conn.findFirstByJsonPathOrdered<'TDoc> tableName jsonPath orderFields =
Find.firstByJsonPathOrdered<'TDoc> tableName jsonPath orderFields (Sql.existingConnection conn)
+ /// Retrieve all documents in the given table as a JSON array
+ /// The table from which documents should be retrieved (may include schema)
+ /// All documents from the given table as a JSON array
+ member conn.jsonAll tableName =
+ Json.all tableName (Sql.existingConnection conn)
+
+ /// Write all documents in the given table to the given StreamWriter
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ member conn.writeJsonAll tableName writer =
+ Json.writeAll tableName writer (Sql.existingConnection conn)
+
+ ///
+ /// Retrieve all documents in the given table as a JSON array, ordered by the given fields in the document
+ ///
+ /// The table from which documents should be retrieved (may include schema)
+ /// Fields by which the results should be ordered
+ /// All documents from the given table as a JSON array, ordered by the given fields
+ member conn.jsonAllOrdered tableName orderFields =
+ Json.allOrdered tableName orderFields (Sql.existingConnection conn)
+
+ ///
+ /// Write all documents in the given table to the given StreamWriter, ordered by the given fields in the
+ /// document
+ ///
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// Fields by which the results should be ordered
+ member conn.writeJsonAllOrdered tableName writer orderFields =
+ Json.writeAllOrdered tableName writer orderFields (Sql.existingConnection conn)
+
+ /// Retrieve a JSON document by its ID
+ /// The table from which a document should be retrieved (may include schema)
+ /// The ID of the document to retrieve
+ /// The JSON document if found, an empty JSON document otherwise
+ member conn.jsonById<'TKey> tableName (docId: 'TKey) =
+ Json.byId tableName docId (Sql.existingConnection conn)
+
+ /// Write a JSON document to the given StreamWriter by its ID
+ /// The table from which a document should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The ID of the document to retrieve
+ member conn.writeJsonById<'TKey> tableName writer (docId: 'TKey) =
+ Json.writeById tableName writer docId (Sql.existingConnection conn)
+
+ /// Retrieve JSON documents matching JSON field comparisons (->> =, etc.)
+ /// The table from which documents should be retrieved (may include schema)
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ /// All JSON documents matching the given fields
+ member conn.jsonByFields tableName howMatched fields =
+ Json.byFields tableName howMatched fields (Sql.existingConnection conn)
+
+ ///
+ /// Write JSON documents to the given StreamWriter matching JSON field comparisons (->> =,
+ /// etc.)
+ ///
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ member conn.writeJsonByFields tableName writer howMatched fields =
+ Json.writeByFields tableName writer howMatched fields (Sql.existingConnection conn)
+
+ ///
+ /// Retrieve JSON documents matching JSON field comparisons (->> =, etc.) ordered by the given
+ /// fields in the document
+ ///
+ /// The table from which documents should be retrieved (may include schema)
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ /// Fields by which the results should be ordered
+ /// All JSON documents matching the given fields, ordered by the other given fields
+ member conn.jsonByFieldsOrdered tableName howMatched queryFields orderFields =
+ Json.byFieldsOrdered tableName howMatched queryFields orderFields (Sql.existingConnection conn)
+
+ ///
+ /// Write JSON documents to the given StreamWriter matching JSON field comparisons (->> =,
+ /// etc.) ordered by the given fields in the document
+ ///
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ /// Fields by which the results should be ordered
+ member conn.writeJsonByFieldsOrdered tableName writer howMatched queryFields orderFields =
+ Json.writeByFieldsOrdered tableName writer howMatched queryFields orderFields (Sql.existingConnection conn)
+
+ /// Retrieve JSON documents matching a JSON containment query (@>)
+ /// The table from which documents should be retrieved (may include schema)
+ /// The document to match with the containment query
+ /// All JSON documents matching the given containment query
+ member conn.jsonByContains tableName (criteria: obj) =
+ Json.byContains tableName criteria (Sql.existingConnection conn)
+
+ ///
+ /// Write JSON documents to the given StreamWriter matching a JSON containment query (@>)
+ ///
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The document to match with the containment query
+ member conn.writeJsonByContains tableName writer (criteria: obj) =
+ Json.writeByContains tableName writer criteria (Sql.existingConnection conn)
+
+ ///
+ /// Retrieve JSON documents matching a JSON containment query (@>) ordered by the given fields in the
+ /// document
+ ///
+ /// The table from which documents should be retrieved (may include schema)
+ /// The document to match with the containment query
+ /// Fields by which the results should be ordered
+ /// All documents matching the given containment query, ordered by the given fields
+ member conn.jsonByContainsOrdered tableName (criteria: obj) orderFields =
+ Json.byContainsOrdered tableName criteria orderFields (Sql.existingConnection conn)
+
+ ///
+ /// Write JSON documents to the given StreamWriter matching a JSON containment query (@>)
+ /// ordered by the given fields in the document
+ ///
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The document to match with the containment query
+ /// Fields by which the results should be ordered
+ member conn.writeJsonByContainsOrdered tableName writer (criteria: obj) orderFields =
+ Json.writeByContainsOrdered tableName writer criteria orderFields (Sql.existingConnection conn)
+
+ /// Retrieve JSON documents matching a JSON Path match query (@?)
+ /// The table from which documents should be retrieved (may include schema)
+ /// The JSON Path expression to match
+ /// All JSON documents matching the given JSON Path expression
+ member conn.jsonByJsonPath tableName jsonPath =
+ Json.byJsonPath tableName jsonPath (Sql.existingConnection conn)
+
+ ///
+ /// Write JSON documents to the given StreamWriter matching a JSON Path match query (@?)
+ ///
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The JSON Path expression to match
+ member conn.writeJsonByJsonPath tableName writer jsonPath =
+ Json.writeByJsonPath tableName writer jsonPath (Sql.existingConnection conn)
+
+ ///
+ /// Retrieve JSON documents matching a JSON Path match query (@?) ordered by the given fields in the
+ /// document
+ ///
+ /// The table from which documents should be retrieved (may include schema)
+ /// The JSON Path expression to match
+ /// Fields by which the results should be ordered
+ /// All JSON documents matching the given JSON Path expression, ordered by the given fields
+ member conn.jsonByJsonPathOrdered tableName jsonPath orderFields =
+ Json.byJsonPathOrdered tableName jsonPath orderFields (Sql.existingConnection conn)
+
+ ///
+ /// Write JSON documents to the given StreamWriter matching a JSON Path match query (@?) ordered
+ /// by the given fields in the document
+ ///
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The JSON Path expression to match
+ /// Fields by which the results should be ordered
+ member conn.writeJsonByJsonPathOrdered tableName writer jsonPath orderFields =
+ Json.writeByJsonPathOrdered tableName writer jsonPath orderFields (Sql.existingConnection conn)
+
+ ///
+ /// Retrieve the first JSON document matching JSON field comparisons (->> =, etc.)
+ ///
+ /// The table from which a document should be retrieved (may include schema)
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ /// The first matching JSON document if found, an empty JSON document otherwise
+ member conn.jsonFirstByFields tableName howMatched fields =
+ Json.firstByFields tableName howMatched fields (Sql.existingConnection conn)
+
+ ///
+ /// Write the first JSON document to the given StreamWriter matching JSON field comparisons
+ /// (->> =, etc.)
+ ///
+ /// The table from which a document should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ member conn.writeJsonFirstByFields tableName writer howMatched fields =
+ Json.writeFirstByFields tableName writer howMatched fields (Sql.existingConnection conn)
+
+ ///
+ /// Retrieve the first JSON document matching JSON field comparisons (->> =, etc.) ordered by the
+ /// given fields in the document
+ ///
+ /// The table from which a document should be retrieved (may include schema)
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ /// Fields by which the results should be ordered
+ /// The first matching JSON document if found, an empty JSON document otherwise
+ member conn.jsonFirstByFieldsOrdered tableName howMatched queryFields orderFields =
+ Json.firstByFieldsOrdered tableName howMatched queryFields orderFields (Sql.existingConnection conn)
+
+ ///
+ /// Write the first JSON document to the given StreamWriter matching JSON field comparisons
+ /// (->> =, etc.) ordered by the given fields in the document
+ ///
+ /// The table from which a document should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ /// Fields by which the results should be ordered
+ member conn.writeJsonFirstByFieldsOrdered tableName writer howMatched queryFields orderFields =
+ Json.writeFirstByFieldsOrdered
+ tableName writer howMatched queryFields orderFields (Sql.existingConnection conn)
+
+ /// Retrieve the first JSON document matching a JSON containment query (@>)
+ /// The table from which a document should be retrieved (may include schema)
+ /// The document to match with the containment query
+ /// The first matching JSON document if found, an empty JSON document otherwise
+ member conn.jsonFirstByContains tableName (criteria: obj) =
+ Json.firstByContains tableName criteria (Sql.existingConnection conn)
+
+ ///
+ /// Write the first JSON document to the given StreamWriter matching a JSON containment query
+ /// (@>)
+ ///
+ /// The table from which a document should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The document to match with the containment query
+ member conn.writeJsonFirstByContains tableName writer (criteria: obj) =
+ Json.writeFirstByContains tableName writer criteria (Sql.existingConnection conn)
+
+ ///
+ /// Retrieve the first JSON document matching a JSON containment query (@>) ordered by the given
+ /// fields in the document
+ ///
+ /// The table from which a document should be retrieved (may include schema)
+ /// The document to match with the containment query
+ /// Fields by which the results should be ordered
+ /// The first matching JSON document if found, an empty JSON document otherwise
+ member conn.jsonFirstByContainsOrdered tableName (criteria: obj) orderFields =
+ Json.firstByContainsOrdered tableName criteria orderFields (Sql.existingConnection conn)
+
+ ///
+ /// Write the first JSON document to the given StreamWriter matching a JSON containment query
+ /// (@>) ordered by the given fields in the document
+ ///
+ /// The table from which a document should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The document to match with the containment query
+ /// Fields by which the results should be ordered
+ member conn.writeJsonFirstByContainsOrdered tableName writer (criteria: obj) orderFields =
+ Json.writeFirstByContainsOrdered tableName writer criteria orderFields (Sql.existingConnection conn)
+
+ /// Retrieve the first JSON document matching a JSON Path match query (@?)
+ /// The table from which a document should be retrieved (may include schema)
+ /// The JSON Path expression to match
+ /// The first matching JSON document if found, an empty JSON document otherwise
+ member conn.jsonFirstByJsonPath tableName jsonPath =
+ Json.firstByJsonPath tableName jsonPath (Sql.existingConnection conn)
+
+ ///
+ /// Write the first JSON document to the given StreamWriter matching a JSON Path match query (@?)
+ ///
+ /// The table from which a document should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The JSON Path expression to match
+ member conn.writeJsonFirstByJsonPath tableName writer jsonPath =
+ Json.writeFirstByJsonPath tableName writer jsonPath (Sql.existingConnection conn)
+
+ ///
+ /// Retrieve the first JSON document matching a JSON Path match query (@?) ordered by the given fields
+ /// in the document
+ ///
+ /// The table from which a document should be retrieved (may include schema)
+ /// The JSON Path expression to match
+ /// Fields by which the results should be ordered
+ /// The first matching JSON document if found, an empty JSON document otherwise
+ member conn.jsonFirstByJsonPathOrdered tableName jsonPath orderFields =
+ Json.firstByJsonPathOrdered tableName jsonPath orderFields (Sql.existingConnection conn)
+
+ ///
+ /// Write the first JSON document to the given StreamWriter matching a JSON Path match query (@?)
+ /// ordered by the given fields in the document
+ ///
+ /// The table from which a document should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The JSON Path expression to match
+ /// Fields by which the results should be ordered
+ member conn.writeJsonFirstByJsonPathOrdered tableName writer jsonPath orderFields =
+ Json.writeFirstByJsonPathOrdered tableName writer jsonPath orderFields (Sql.existingConnection conn)
+
/// Update (replace) an entire document by its ID
/// The table in which a document should be updated (may include schema)
/// The ID of the document to be updated (replaced)
@@ -381,7 +692,7 @@ open System.Runtime.CompilerServices
type NpgsqlConnectionCSharpExtensions =
/// Execute a query that returns a list of results
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The query to retrieve the results
/// Parameters to use for the query
/// The mapping function between the document and the domain item
@@ -390,8 +701,26 @@ type NpgsqlConnectionCSharpExtensions =
static member inline CustomList<'TDoc>(conn, query, parameters, mapFunc: System.Func) =
Custom.List<'TDoc>(query, parameters, mapFunc, Sql.existingConnection conn)
+ /// Execute a query that returns a JSON array of results
+ /// The NpgsqlConnection on which to run the query
+ /// The query to retrieve the results
+ /// Parameters to use for the query
+ /// The mapping function to extract the document
+ /// A JSON array of results for the given query
+ static member inline CustomJsonArray(conn, query, parameters, mapFunc) =
+ Custom.JsonArray(query, parameters, mapFunc, Sql.existingConnection conn)
+
+ /// Execute a query, writing its results to the given StreamWriter
+ /// The NpgsqlConnection on which to run the query
+ /// The query to retrieve the results
+ /// Parameters to use for the query
+ /// The StreamWriter to which the results should be written
+ /// The mapping function to extract the document
+ static member inline WriteCustomJsonArray(conn, query, parameters, writer, mapFunc) =
+ Custom.WriteJsonArray(query, parameters, writer, mapFunc, Sql.existingConnection conn)
+
/// Execute a query that returns one or no results
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The query to retrieve the results
/// Parameters to use for the query
/// The mapping function between the document and the domain item
@@ -401,8 +730,17 @@ type NpgsqlConnectionCSharpExtensions =
conn, query, parameters, mapFunc: System.Func) =
Custom.Single<'TDoc>(query, parameters, mapFunc, Sql.existingConnection conn)
+ /// Execute a query that returns one or no JSON documents
+ /// The NpgsqlConnection on which to run the query
+ /// The query to retrieve the results
+ /// Parameters to use for the query
+ /// The mapping function to extract the document
+ /// The JSON document with the first matching result, or an empty document if not found
+ static member inline CustomJsonSingle(conn, query, parameters, mapFunc) =
+ Custom.JsonSingle(query, parameters, mapFunc, Sql.existingConnection conn)
+
/// Execute a query that returns no results
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The query to retrieve the results
/// Parameters to use for the query
[]
@@ -410,7 +748,7 @@ type NpgsqlConnectionCSharpExtensions =
Custom.nonQuery query parameters (Sql.existingConnection conn)
/// Execute a query that returns a scalar value
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The query to retrieve the value
/// Parameters to use for the query
/// The mapping function to obtain the value
@@ -421,14 +759,14 @@ type NpgsqlConnectionCSharpExtensions =
Custom.Scalar(query, parameters, mapFunc, Sql.existingConnection conn)
/// Create a document table
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table whose existence should be ensured (may include schema)
[]
static member inline EnsureTable(conn, name) =
Definition.ensureTable name (Sql.existingConnection conn)
/// Create an index on documents in the specified table
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table to be indexed (may include schema)
/// The type of document index to create
[]
@@ -436,7 +774,7 @@ type NpgsqlConnectionCSharpExtensions =
Definition.ensureDocumentIndex name idxType (Sql.existingConnection conn)
/// Create an index on field(s) within documents in the specified table
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table to be indexed (may include schema)
/// The name of the index to create
/// One or more fields to be indexed
@@ -445,7 +783,7 @@ type NpgsqlConnectionCSharpExtensions =
Definition.ensureFieldIndex tableName indexName fields (Sql.existingConnection conn)
/// Insert a new document
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table into which the document should be inserted (may include schema)
/// The document to be inserted
[]
@@ -453,7 +791,7 @@ type NpgsqlConnectionCSharpExtensions =
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")
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table into which the document should be saved (may include schema)
/// The document to be saved
[]
@@ -461,7 +799,7 @@ type NpgsqlConnectionCSharpExtensions =
save<'TDoc> tableName document (Sql.existingConnection conn)
/// Count all documents in a table
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table in which documents should be counted (may include schema)
/// The count of the documents in the table
[]
@@ -469,7 +807,7 @@ type NpgsqlConnectionCSharpExtensions =
Count.all tableName (Sql.existingConnection conn)
/// Count matching documents using JSON field comparisons (->> =, etc.)
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table in which documents should be counted (may include schema)
/// Whether to match any or all of the field conditions
/// The field conditions to match
@@ -479,7 +817,7 @@ type NpgsqlConnectionCSharpExtensions =
Count.byFields tableName howMatched fields (Sql.existingConnection conn)
/// Count matching documents using a JSON containment query (@>)
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table in which documents should be counted (may include schema)
/// The document to match with the containment query
/// The count of the documents in the table
@@ -488,7 +826,7 @@ type NpgsqlConnectionCSharpExtensions =
Count.byContains tableName criteria (Sql.existingConnection conn)
/// Count matching documents using a JSON Path match query (@?)
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table in which documents should be counted (may include schema)
/// The JSON Path expression to be matched
/// The count of the documents in the table
@@ -497,7 +835,7 @@ type NpgsqlConnectionCSharpExtensions =
Count.byJsonPath tableName jsonPath (Sql.existingConnection conn)
/// Determine if a document exists for the given ID
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table in which existence should be checked (may include schema)
/// The ID of the document whose existence should be checked
/// True if a document exists, false if not
@@ -506,7 +844,7 @@ type NpgsqlConnectionCSharpExtensions =
Exists.byId tableName docId (Sql.existingConnection conn)
/// Determine if a document exists using JSON field comparisons (->> =, etc.)
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table in which existence should be checked (may include schema)
/// Whether to match any or all of the field conditions
/// The field conditions to match
@@ -516,7 +854,7 @@ type NpgsqlConnectionCSharpExtensions =
Exists.byFields tableName howMatched fields (Sql.existingConnection conn)
/// Determine if a document exists using a JSON containment query (@>)
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table in which existence should be checked (may include schema)
/// The document to match with the containment query
/// True if any matching documents exist, false if not
@@ -525,7 +863,7 @@ type NpgsqlConnectionCSharpExtensions =
Exists.byContains tableName criteria (Sql.existingConnection conn)
/// Determine if a document exists using a JSON Path match query (@?)
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table in which existence should be checked (may include schema)
/// The JSON Path expression to be matched
/// True if any matching documents exist, false if not
@@ -534,7 +872,7 @@ type NpgsqlConnectionCSharpExtensions =
Exists.byJsonPath tableName jsonPath (Sql.existingConnection conn)
/// Retrieve all documents in the given table
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table from which documents should be retrieved (may include schema)
/// All documents from the given table
[]
@@ -542,7 +880,7 @@ type NpgsqlConnectionCSharpExtensions =
Find.All<'TDoc>(tableName, Sql.existingConnection conn)
/// Retrieve all documents in the given table ordered by the given fields in the document
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table from which documents should be retrieved (may include schema)
/// Fields by which the results should be ordered
/// All documents from the given table, ordered by the given fields
@@ -551,7 +889,7 @@ type NpgsqlConnectionCSharpExtensions =
Find.AllOrdered<'TDoc>(tableName, orderFields, Sql.existingConnection conn)
/// Retrieve a document by its ID
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table from which a document should be retrieved (may include schema)
/// The ID of the document to retrieve
/// The document if found, null otherwise
@@ -560,7 +898,7 @@ type NpgsqlConnectionCSharpExtensions =
Find.ById<'TKey, 'TDoc>(tableName, docId, Sql.existingConnection conn)
/// Retrieve documents matching JSON field comparisons (->> =, etc.)
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table from which documents should be retrieved (may include schema)
/// Whether to match any or all of the field conditions
/// The field conditions to match
@@ -573,7 +911,7 @@ type NpgsqlConnectionCSharpExtensions =
/// Retrieve documents matching JSON field comparisons (->> =, etc.) ordered by the given fields in
/// the document
///
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table from which documents should be retrieved (may include schema)
/// Whether to match any or all of the field conditions
/// The field conditions to match
@@ -585,7 +923,7 @@ type NpgsqlConnectionCSharpExtensions =
tableName, howMatched, queryFields, orderFields, Sql.existingConnection conn)
/// Retrieve documents matching a JSON containment query (@>)
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table from which documents should be retrieved (may include schema)
/// The document to match with the containment query
/// All documents matching the given containment query
@@ -597,7 +935,7 @@ type NpgsqlConnectionCSharpExtensions =
/// Retrieve documents matching a JSON containment query (@>) ordered by the given fields in the
/// document
///
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table from which documents should be retrieved (may include schema)
/// The document to match with the containment query
/// Fields by which the results should be ordered
@@ -607,7 +945,7 @@ type NpgsqlConnectionCSharpExtensions =
Find.ByContainsOrdered<'TDoc>(tableName, criteria, orderFields, Sql.existingConnection conn)
/// Retrieve documents matching a JSON Path match query (@?)
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table from which documents should be retrieved (may include schema)
/// The JSON Path expression to match
/// All documents matching the given JSON Path expression
@@ -618,7 +956,7 @@ type NpgsqlConnectionCSharpExtensions =
///
/// Retrieve documents matching a JSON Path match query (@?) ordered by the given fields in the document
///
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table from which documents should be retrieved (may include schema)
/// The JSON Path expression to match
/// Fields by which the results should be ordered
@@ -628,7 +966,7 @@ type NpgsqlConnectionCSharpExtensions =
Find.ByJsonPathOrdered<'TDoc>(tableName, jsonPath, orderFields, Sql.existingConnection conn)
/// Retrieve the first document matching JSON field comparisons (->> =, etc.)
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table from which a document should be retrieved (may include schema)
/// Whether to match any or all of the field conditions
/// The field conditions to match
@@ -642,7 +980,7 @@ type NpgsqlConnectionCSharpExtensions =
/// Retrieve the first document matching JSON field comparisons (->> =, etc.) ordered by the given
/// fields in the document
///
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table from which a document should be retrieved (may include schema)
/// Whether to match any or all of the field conditions
/// The field conditions to match
@@ -655,7 +993,7 @@ type NpgsqlConnectionCSharpExtensions =
tableName, howMatched, queryFields, orderFields, Sql.existingConnection conn)
/// Retrieve the first document matching a JSON containment query (@>)
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table from which a document should be retrieved (may include schema)
/// The document to match with the containment query
/// The first document, or null if not found
@@ -668,7 +1006,7 @@ type NpgsqlConnectionCSharpExtensions =
/// Retrieve the first document matching a JSON containment query (@>) ordered by the given fields in
/// the document
///
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table from which a document should be retrieved (may include schema)
/// The document to match with the containment query
/// Fields by which the results should be ordered
@@ -679,7 +1017,7 @@ type NpgsqlConnectionCSharpExtensions =
Find.FirstByContainsOrdered<'TDoc>(tableName, criteria, orderFields, Sql.existingConnection conn)
/// Retrieve the first document matching a JSON Path match query (@?)
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table from which a document should be retrieved (may include schema)
/// The JSON Path expression to match
/// The first document, or null if not found
@@ -691,7 +1029,7 @@ type NpgsqlConnectionCSharpExtensions =
/// Retrieve the first document matching a JSON Path match query (@?) ordered by the given fields in the
/// document
///
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table from which a document should be retrieved (may include schema)
/// The JSON Path expression to match
/// Fields by which the results should be ordered
@@ -701,8 +1039,355 @@ type NpgsqlConnectionCSharpExtensions =
conn, tableName, jsonPath, orderFields) =
Find.FirstByJsonPathOrdered<'TDoc>(tableName, jsonPath, orderFields, Sql.existingConnection conn)
+ /// Retrieve all documents in the given table as a JSON array
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which documents should be retrieved (may include schema)
+ /// All documents from the given table as a JSON array
+ []
+ static member inline JsonAll(conn, tableName) =
+ Json.all tableName (Sql.existingConnection conn)
+
+ /// Write all documents in the given table to the given StreamWriter
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ []
+ static member inline WriteJsonAll(conn, tableName, writer) =
+ Json.writeAll tableName writer (Sql.existingConnection conn)
+
+ ///
+ /// Retrieve all documents in the given table as a JSON array, ordered by the given fields in the document
+ ///
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which documents should be retrieved (may include schema)
+ /// Fields by which the results should be ordered
+ /// All documents from the given table as a JSON array, ordered by the given fields
+ []
+ static member inline JsonAllOrdered(conn, tableName, orderFields) =
+ Json.allOrdered tableName orderFields (Sql.existingConnection conn)
+
+ ///
+ /// Write all documents in the given table to the given StreamWriter, ordered by the given fields in the
+ /// document
+ ///
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// Fields by which the results should be ordered
+ []
+ static member inline WriteJsonAllOrdered(conn, tableName, writer, orderFields) =
+ Json.writeAllOrdered tableName writer orderFields (Sql.existingConnection conn)
+
+ /// Retrieve a JSON document by its ID
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which a document should be retrieved (may include schema)
+ /// The ID of the document to retrieve
+ /// The JSON document if found, an empty JSON document otherwise
+ []
+ static member inline JsonById<'TKey>(conn, tableName, docId: 'TKey) =
+ Json.byId tableName docId (Sql.existingConnection conn)
+
+ /// Write a JSON document to the given StreamWriter by its ID
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which a document should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The ID of the document to retrieve
+ []
+ static member inline WriteJsonById<'TKey>(conn, tableName, writer, docId) =
+ Json.writeById tableName writer docId (Sql.existingConnection conn)
+
+ /// Retrieve JSON documents matching JSON field comparisons (->> =, etc.)
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which documents should be retrieved (may include schema)
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ /// All JSON documents matching the given fields
+ []
+ static member inline JsonByFields(conn, tableName, howMatched, fields) =
+ Json.byFields tableName howMatched fields (Sql.existingConnection conn)
+
+ ///
+ /// Write JSON documents to the given StreamWriter matching JSON field comparisons (->> =,
+ /// etc.)
+ ///
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ []
+ static member inline WriteJsonByFields(conn, tableName, writer, howMatched, fields) =
+ Json.writeByFields tableName writer howMatched fields (Sql.existingConnection conn)
+
+ ///
+ /// Retrieve JSON documents matching JSON field comparisons (->> =, etc.) ordered by the given
+ /// fields in the document
+ ///
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which documents should be retrieved (may include schema)
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ /// Fields by which the results should be ordered
+ /// All JSON documents matching the given fields, ordered by the other given fields
+ []
+ static member inline JsonByFieldsOrdered(conn, tableName, howMatched, queryFields, orderFields) =
+ Json.byFieldsOrdered tableName howMatched queryFields orderFields (Sql.existingConnection conn)
+
+ ///
+ /// Write JSON documents to the given StreamWriter matching JSON field comparisons (->> =,
+ /// etc.) ordered by the given fields in the document
+ ///
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ /// Fields by which the results should be ordered
+ []
+ static member inline WriteJsonByFieldsOrdered(conn, tableName, writer, howMatched, queryFields, orderFields) =
+ Json.writeByFieldsOrdered tableName writer howMatched queryFields orderFields (Sql.existingConnection conn)
+
+ /// Retrieve JSON documents matching a JSON containment query (@>)
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which documents should be retrieved (may include schema)
+ /// The document to match with the containment query
+ /// All JSON documents matching the given containment query
+ []
+ static member inline JsonByContains(conn, tableName, criteria: obj) =
+ Json.byContains tableName criteria (Sql.existingConnection conn)
+
+ ///
+ /// Write JSON documents to the given StreamWriter matching a JSON containment query (@>)
+ ///
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The document to match with the containment query
+ []
+ static member inline WriteJsonByContains(conn, tableName, writer, criteria: obj) =
+ Json.writeByContains tableName writer criteria (Sql.existingConnection conn)
+
+ ///
+ /// Retrieve JSON documents matching a JSON containment query (@>) ordered by the given fields in the
+ /// document
+ ///
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which documents should be retrieved (may include schema)
+ /// The document to match with the containment query
+ /// Fields by which the results should be ordered
+ /// All documents matching the given containment query, ordered by the given fields
+ []
+ static member inline JsonByContainsOrdered(conn, tableName, criteria: obj, orderFields) =
+ Json.byContainsOrdered tableName criteria orderFields (Sql.existingConnection conn)
+
+ ///
+ /// Write JSON documents to the given StreamWriter matching a JSON containment query (@>)
+ /// ordered by the given fields in the document
+ ///
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The document to match with the containment query
+ /// Fields by which the results should be ordered
+ []
+ static member inline WriteJsonByContainsOrdered(conn, tableName, writer, criteria: obj, orderFields) =
+ Json.writeByContainsOrdered tableName writer criteria orderFields (Sql.existingConnection conn)
+
+ /// Retrieve JSON documents matching a JSON Path match query (@?)
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which documents should be retrieved (may include schema)
+ /// The JSON Path expression to match
+ /// All JSON documents matching the given JSON Path expression
+ []
+ static member inline JsonByJsonPath(conn, tableName, jsonPath) =
+ Json.byJsonPath tableName jsonPath (Sql.existingConnection conn)
+
+ ///
+ /// Write JSON documents to the given StreamWriter matching a JSON Path match query (@?)
+ ///
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The JSON Path expression to match
+ []
+ static member inline WriteJsonByJsonPath(conn, tableName, writer, jsonPath) =
+ Json.writeByJsonPath tableName writer jsonPath (Sql.existingConnection conn)
+
+ ///
+ /// Retrieve JSON documents matching a JSON Path match query (@?) ordered by the given fields in the
+ /// document
+ ///
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which documents should be retrieved (may include schema)
+ /// The JSON Path expression to match
+ /// Fields by which the results should be ordered
+ /// All JSON documents matching the given JSON Path expression, ordered by the given fields
+ []
+ static member inline JsonByJsonPathOrdered(conn, tableName, jsonPath, orderFields) =
+ Json.byJsonPathOrdered tableName jsonPath orderFields (Sql.existingConnection conn)
+
+ ///
+ /// Write JSON documents to the given StreamWriter matching a JSON Path match query (@?) ordered
+ /// by the given fields in the document
+ ///
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The JSON Path expression to match
+ /// Fields by which the results should be ordered
+ []
+ static member inline WriteJsonByJsonPathOrdered(conn, tableName, writer, jsonPath, orderFields) =
+ Json.writeByJsonPathOrdered tableName writer jsonPath orderFields (Sql.existingConnection conn)
+
+ ///
+ /// Retrieve the first JSON document matching JSON field comparisons (->> =, etc.)
+ ///
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which a document should be retrieved (may include schema)
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ /// The first matching JSON document if found, an empty JSON document otherwise
+ []
+ static member inline JsonFirstByFields(conn, tableName, howMatched, fields) =
+ Json.firstByFields tableName howMatched fields (Sql.existingConnection conn)
+
+ ///
+ /// Write the first JSON document to the given StreamWriter matching JSON field comparisons
+ /// (->> =, etc.)
+ ///
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which a document should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ []
+ static member inline WriteJsonFirstByFields(conn, tableName, writer, howMatched, fields) =
+ Json.writeFirstByFields tableName writer howMatched fields (Sql.existingConnection conn)
+
+ ///
+ /// Retrieve the first JSON document matching JSON field comparisons (->> =, etc.) ordered by the
+ /// given fields in the document
+ ///
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which a document should be retrieved (may include schema)
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ /// Fields by which the results should be ordered
+ /// The first matching JSON document if found, an empty JSON document otherwise
+ []
+ static member inline JsonFirstByFieldsOrdered(conn, tableName, howMatched, queryFields, orderFields) =
+ Json.firstByFieldsOrdered tableName howMatched queryFields orderFields (Sql.existingConnection conn)
+
+ ///
+ /// Write the first JSON document to the given StreamWriter matching JSON field comparisons
+ /// (->> =, etc.) ordered by the given fields in the document
+ ///
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which a document should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ /// Fields by which the results should be ordered
+ []
+ static member inline WriteJsonFirstByFieldsOrdered(conn, tableName, writer, howMatched, queryFields, orderFields) =
+ Json.writeFirstByFieldsOrdered
+ tableName writer howMatched queryFields orderFields (Sql.existingConnection conn)
+
+ /// Retrieve the first JSON document matching a JSON containment query (@>)
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which a document should be retrieved (may include schema)
+ /// The document to match with the containment query
+ /// The first matching JSON document if found, an empty JSON document otherwise
+ []
+ static member inline JsonFirstByContains(conn, tableName, criteria: obj) =
+ Json.firstByContains tableName criteria (Sql.existingConnection conn)
+
+ ///
+ /// Write the first JSON document to the given StreamWriter matching a JSON containment query
+ /// (@>)
+ ///
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which a document should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The document to match with the containment query
+ []
+ static member inline WriteJsonFirstByContains(conn, tableName, writer, criteria: obj) =
+ Json.writeFirstByContains tableName writer criteria (Sql.existingConnection conn)
+
+ ///
+ /// Retrieve the first JSON document matching a JSON containment query (@>) ordered by the given
+ /// fields in the document
+ ///
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which a document should be retrieved (may include schema)
+ /// The document to match with the containment query
+ /// Fields by which the results should be ordered
+ /// The first matching JSON document if found, an empty JSON document otherwise
+ []
+ static member inline JsonFirstByContainsOrdered(conn, tableName, criteria: obj, orderFields) =
+ Json.firstByContainsOrdered tableName criteria orderFields (Sql.existingConnection conn)
+
+ ///
+ /// Write the first JSON document to the given StreamWriter matching a JSON containment query
+ /// (@>) ordered by the given fields in the document
+ ///
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which a document should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The document to match with the containment query
+ /// Fields by which the results should be ordered
+ []
+ static member inline WriteJsonFirstByContainsOrdered(conn, tableName, writer, criteria: obj, orderFields) =
+ Json.writeFirstByContainsOrdered tableName writer criteria orderFields (Sql.existingConnection conn)
+
+ /// Retrieve the first JSON document matching a JSON Path match query (@?)
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which a document should be retrieved (may include schema)
+ /// The JSON Path expression to match
+ /// The first matching JSON document if found, an empty JSON document otherwise
+ []
+ static member inline JsonFirstByJsonPath(conn, tableName, jsonPath) =
+ Json.firstByJsonPath tableName jsonPath (Sql.existingConnection conn)
+
+ ///
+ /// Write the first JSON document to the given StreamWriter matching a JSON Path match query (@?)
+ ///
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which a document should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The JSON Path expression to match
+ []
+ static member inline WriteJsonFirstByJsonPath(conn, tableName, writer, jsonPath) =
+ Json.writeFirstByJsonPath tableName writer jsonPath (Sql.existingConnection conn)
+
+ ///
+ /// Retrieve the first JSON document matching a JSON Path match query (@?) ordered by the given fields
+ /// in the document
+ ///
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which a document should be retrieved (may include schema)
+ /// The JSON Path expression to match
+ /// Fields by which the results should be ordered
+ /// The first matching JSON document if found, an empty JSON document otherwise
+ []
+ static member inline JsonFirstByJsonPathOrdered(conn, tableName, jsonPath, orderFields) =
+ Json.firstByJsonPathOrdered tableName jsonPath orderFields (Sql.existingConnection conn)
+
+ ///
+ /// Write the first JSON document to the given StreamWriter matching a JSON Path match query (@?)
+ /// ordered by the given fields in the document
+ ///
+ /// The NpgsqlConnection on which to run the query
+ /// The table from which a document should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The JSON Path expression to match
+ /// Fields by which the results should be ordered
+ []
+ static member inline WriteJsonFirstByJsonPathOrdered(conn, tableName, writer, jsonPath, orderFields) =
+ Json.writeFirstByJsonPathOrdered tableName writer jsonPath orderFields (Sql.existingConnection conn)
+
/// Update (replace) an entire document by its ID
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table in which a document should be updated (may include schema)
/// The ID of the document to be updated (replaced)
/// The new document
@@ -713,7 +1398,7 @@ type NpgsqlConnectionCSharpExtensions =
///
/// Update (replace) an entire document by its ID, using the provided function to obtain the ID from the document
///
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table in which a document should be updated (may include schema)
/// The function to obtain the ID of the document
/// The new document
@@ -722,7 +1407,7 @@ type NpgsqlConnectionCSharpExtensions =
Update.ByFunc(tableName, idFunc, document, Sql.existingConnection conn)
/// Patch a document by its ID
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table in which a document should be patched (may include schema)
/// The ID of the document to patch
/// The partial document to patch the existing document
@@ -733,7 +1418,7 @@ type NpgsqlConnectionCSharpExtensions =
///
/// Patch documents using a JSON field comparison query in the WHERE clause (->> =, etc.)
///
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table in which documents should be patched (may include schema)
/// Whether to match any or all of the field conditions
/// The field conditions to match
@@ -743,7 +1428,7 @@ type NpgsqlConnectionCSharpExtensions =
Patch.byFields tableName howMatched fields patch (Sql.existingConnection conn)
/// Patch documents using a JSON containment query in the WHERE clause (@>)
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table in which documents should be patched (may include schema)
/// The document to match the containment query
/// The partial document to patch the existing document
@@ -752,7 +1437,7 @@ type NpgsqlConnectionCSharpExtensions =
Patch.byContains tableName criteria patch (Sql.existingConnection conn)
/// Patch documents using a JSON Path match query in the WHERE clause (@?)
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table in which documents should be patched (may include schema)
/// The JSON Path expression to match
/// The partial document to patch the existing document
@@ -761,7 +1446,7 @@ type NpgsqlConnectionCSharpExtensions =
Patch.byJsonPath tableName jsonPath patch (Sql.existingConnection conn)
/// Remove fields from a document by the document's ID
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table in which a document should be modified (may include schema)
/// The ID of the document to modify
/// One or more field names to remove from the document
@@ -770,7 +1455,7 @@ type NpgsqlConnectionCSharpExtensions =
RemoveFields.byId tableName docId fieldNames (Sql.existingConnection conn)
/// Remove fields from documents via a comparison on JSON fields in the document
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table in which documents should be modified (may include schema)
/// Whether to match any or all of the field conditions
/// The field conditions to match
@@ -780,7 +1465,7 @@ type NpgsqlConnectionCSharpExtensions =
RemoveFields.byFields tableName howMatched fields fieldNames (Sql.existingConnection conn)
/// Remove fields from documents via a JSON containment query (@>)
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table in which documents should be modified (may include schema)
/// The document to match the containment query
/// One or more field names to remove from the matching documents
@@ -789,7 +1474,7 @@ type NpgsqlConnectionCSharpExtensions =
RemoveFields.byContains tableName criteria fieldNames (Sql.existingConnection conn)
/// Remove fields from documents via a JSON Path match query (@?)
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table in which documents should be modified (may include schema)
/// The JSON Path expression to match
/// One or more field names to remove from the matching documents
@@ -798,7 +1483,7 @@ type NpgsqlConnectionCSharpExtensions =
RemoveFields.byJsonPath tableName jsonPath fieldNames (Sql.existingConnection conn)
/// Delete a document by its ID
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table in which a document should be deleted (may include schema)
/// The ID of the document to delete
[]
@@ -806,7 +1491,7 @@ type NpgsqlConnectionCSharpExtensions =
Delete.byId tableName docId (Sql.existingConnection conn)
/// Delete documents by matching a JSON field comparison query (->> =, etc.)
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table in which documents should be deleted (may include schema)
/// Whether to match any or all of the field conditions
/// The field conditions to match
@@ -815,7 +1500,7 @@ type NpgsqlConnectionCSharpExtensions =
Delete.byFields tableName howMatched fields (Sql.existingConnection conn)
/// Delete documents by matching a JSON contains query (@>)
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table in which documents should be deleted (may include schema)
/// The document to match the containment query
[]
@@ -823,7 +1508,7 @@ type NpgsqlConnectionCSharpExtensions =
Delete.byContains tableName criteria (Sql.existingConnection conn)
/// Delete documents by matching a JSON Path match query (@?)
- /// The NpgsqlConnection on which to run the query
+ /// The NpgsqlConnection on which to run the query
/// The table in which documents should be deleted (may include schema)
/// The JSON Path expression to match
[]
diff --git a/src/Postgres/Functions.fs b/src/Postgres/Functions.fs
index fb189e9..910fb90 100644
--- a/src/Postgres/Functions.fs
+++ b/src/Postgres/Functions.fs
@@ -21,6 +21,40 @@ module Custom =
let List<'TDoc>(query, parameters, mapFunc: System.Func) =
WithProps.Custom.List<'TDoc>(query, parameters, mapFunc, fromDataSource ())
+ /// Execute a query that returns a JSON array of results
+ /// The query to retrieve the results
+ /// Parameters to use for the query
+ /// The mapping function to extract the document
+ /// A JSON array of results for the given query
+ []
+ let jsonArray query parameters mapFunc =
+ WithProps.Custom.jsonArray query parameters mapFunc (fromDataSource ())
+
+ /// Execute a query that returns a JSON array of results
+ /// The query to retrieve the results
+ /// Parameters to use for the query
+ /// The mapping function to extract the document
+ /// A JSON array of results for the given query
+ let JsonArray(query, parameters, mapFunc) =
+ WithProps.Custom.JsonArray(query, parameters, mapFunc, fromDataSource ())
+
+ /// Execute a query, writing its results to the given StreamWriter
+ /// The query to retrieve the results
+ /// Parameters to use for the query
+ /// The StreamWriter to which the results should be written
+ /// The mapping function to extract the document
+ []
+ let writeJsonArray query parameters writer mapFunc =
+ WithProps.Custom.writeJsonArray query parameters writer mapFunc
+
+ /// Execute a query, writing its results to the given StreamWriter
+ /// The query to retrieve the results
+ /// Parameters to use for the query
+ /// The StreamWriter to which the results should be written
+ /// The mapping function to extract the document
+ let WriteJsonArray(query, parameters, writer, mapFunc) =
+ WithProps.Custom.WriteJsonArray(query, parameters, writer, mapFunc, fromDataSource ())
+
/// Execute a query that returns one or no results
/// The query to retrieve the results
/// Parameters to use for the query
@@ -39,6 +73,23 @@ module Custom =
query, parameters, mapFunc: System.Func) =
WithProps.Custom.Single<'TDoc>(query, parameters, mapFunc, fromDataSource ())
+ /// Execute a query that returns one or no JSON documents
+ /// The query to retrieve the results
+ /// Parameters to use for the query
+ /// The mapping function to extract the document
+ /// The JSON document with the first matching result, or an empty document if not found
+ []
+ let jsonSingle query parameters mapFunc =
+ WithProps.Custom.jsonSingle query parameters mapFunc (fromDataSource ())
+
+ /// Execute a query that returns one or no JSON documents
+ /// The query to retrieve the results
+ /// Parameters to use for the query
+ /// The mapping function to extract the document
+ /// The JSON document with the first matching result, or an empty document if not found
+ let JsonSingle(query, parameters, mapFunc) =
+ WithProps.Custom.JsonSingle(query, parameters, mapFunc, fromDataSource ())
+
/// Execute a query that returns no results
/// The query to retrieve the results
/// Parameters to use for the query
@@ -184,7 +235,7 @@ module Exists =
WithProps.Exists.byJsonPath tableName jsonPath (fromDataSource ())
-/// Commands to retrieve documents
+/// Commands to retrieve documents as domain objects
[]
module Find =
@@ -473,6 +524,322 @@ module Find =
WithProps.Find.FirstByJsonPathOrdered<'TDoc>(tableName, jsonPath, orderFields, fromDataSource ())
+/// Commands to retrieve documents as JSON
+[]
+module Json =
+
+ /// Retrieve all documents in the given table as a JSON array
+ /// The table from which documents should be retrieved (may include schema)
+ /// All documents from the given table as a JSON array
+ []
+ let all tableName =
+ WithProps.Json.all tableName (fromDataSource ())
+
+ /// Write all documents in the given table to the given StreamWriter
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ []
+ let writeAll tableName writer =
+ WithProps.Json.writeAll tableName writer (fromDataSource ())
+
+ ///
+ /// Retrieve all documents in the given table as a JSON array, ordered by the given fields in the document
+ ///
+ /// The table from which documents should be retrieved (may include schema)
+ /// Fields by which the results should be ordered
+ /// All documents from the given table as a JSON array, ordered by the given fields
+ []
+ let allOrdered tableName orderFields =
+ WithProps.Json.allOrdered tableName orderFields (fromDataSource ())
+
+ ///
+ /// Write all documents in the given table to the given StreamWriter, ordered by the given fields in the
+ /// document
+ ///
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// Fields by which the results should be ordered
+ []
+ let writeAllOrdered tableName writer orderFields =
+ WithProps.Json.writeAllOrdered tableName writer orderFields (fromDataSource ())
+
+ /// Retrieve a JSON document by its ID
+ /// The table from which a document should be retrieved (may include schema)
+ /// The ID of the document to retrieve
+ /// The JSON document if found, an empty JSON document otherwise
+ []
+ let byId<'TKey> tableName (docId: 'TKey) =
+ WithProps.Json.byId tableName docId (fromDataSource ())
+
+ /// Write a JSON document to the given StreamWriter by its ID
+ /// The table from which a document should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The ID of the document to retrieve
+ []
+ let writeById<'TKey> tableName writer (docId: 'TKey) =
+ WithProps.Json.writeById tableName writer docId (fromDataSource ())
+
+ /// Retrieve JSON documents matching JSON field comparisons (->> =, etc.)
+ /// The table from which documents should be retrieved (may include schema)
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ /// All JSON documents matching the given fields
+ []
+ let byFields tableName howMatched fields =
+ WithProps.Json.byFields tableName howMatched fields (fromDataSource ())
+
+ ///
+ /// Write JSON documents to the given StreamWriter matching JSON field comparisons (->> =, etc.)
+ ///
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ []
+ let writeByFields tableName writer howMatched fields =
+ WithProps.Json.writeByFields tableName writer howMatched fields (fromDataSource ())
+
+ ///
+ /// Retrieve JSON documents matching JSON field comparisons (->> =, etc.) ordered by the given fields
+ /// in the document
+ ///
+ /// The table from which documents should be retrieved (may include schema)
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ /// Fields by which the results should be ordered
+ /// All JSON documents matching the given fields, ordered by the other given fields
+ []
+ let byFieldsOrdered tableName howMatched queryFields orderFields =
+ WithProps.Json.byFieldsOrdered tableName howMatched queryFields orderFields (fromDataSource ())
+
+ ///
+ /// Write JSON documents to the given StreamWriter matching JSON field comparisons (->> =, etc.)
+ /// ordered by the given fields in the document
+ ///
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ /// Fields by which the results should be ordered
+ []
+ let writeByFieldsOrdered tableName writer howMatched queryFields orderFields =
+ WithProps.Json.writeByFieldsOrdered tableName writer howMatched queryFields orderFields (fromDataSource ())
+
+ /// Retrieve JSON documents matching a JSON containment query (@>)
+ /// The table from which documents should be retrieved (may include schema)
+ /// The document to match with the containment query
+ /// All JSON documents matching the given containment query
+ []
+ let byContains tableName (criteria: obj) =
+ WithProps.Json.byContains tableName criteria (fromDataSource ())
+
+ ///
+ /// Write JSON documents to the given StreamWriter matching a JSON containment query (@>)
+ ///
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The document to match with the containment query
+ []
+ let writeByContains tableName writer (criteria: obj) =
+ WithProps.Json.writeByContains tableName writer criteria (fromDataSource ())
+
+ ///
+ /// Retrieve JSON documents matching a JSON containment query (@>) ordered by the given fields in the
+ /// document
+ ///
+ /// The table from which documents should be retrieved (may include schema)
+ /// The document to match with the containment query
+ /// Fields by which the results should be ordered
+ /// All documents matching the given containment query, ordered by the given fields
+ []
+ let byContainsOrdered tableName (criteria: obj) orderFields =
+ WithProps.Json.byContainsOrdered tableName criteria orderFields (fromDataSource ())
+
+ ///
+ /// Write JSON documents to the given StreamWriter matching a JSON containment query (@>) ordered
+ /// by the given fields in the document
+ ///
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The document to match with the containment query
+ /// Fields by which the results should be ordered
+ []
+ let writeByContainsOrdered tableName writer (criteria: obj) orderFields =
+ WithProps.Json.writeByContainsOrdered tableName writer criteria orderFields (fromDataSource ())
+
+ /// Retrieve JSON documents matching a JSON Path match query (@?)
+ /// The table from which documents should be retrieved (may include schema)
+ /// The JSON Path expression to match
+ /// All JSON documents matching the given JSON Path expression
+ []
+ let byJsonPath tableName jsonPath =
+ WithProps.Json.byJsonPath tableName jsonPath (fromDataSource ())
+
+ ///
+ /// Write JSON documents to the given StreamWriter matching a JSON Path match query (@?)
+ ///
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The JSON Path expression to match
+ []
+ let writeByJsonPath tableName writer jsonPath =
+ WithProps.Json.writeByJsonPath tableName writer jsonPath (fromDataSource ())
+
+ ///
+ /// Retrieve JSON documents matching a JSON Path match query (@?) ordered by the given fields in the document
+ ///
+ /// The table from which documents should be retrieved (may include schema)
+ /// The JSON Path expression to match
+ /// Fields by which the results should be ordered
+ /// All JSON documents matching the given JSON Path expression, ordered by the given fields
+ []
+ let byJsonPathOrdered tableName jsonPath orderFields =
+ WithProps.Json.byJsonPathOrdered tableName jsonPath orderFields (fromDataSource ())
+
+ ///
+ /// Write JSON documents to the given StreamWriter matching a JSON Path match query (@?) ordered by
+ /// the given fields in the document
+ ///
+ /// The table from which documents should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The JSON Path expression to match
+ /// Fields by which the results should be ordered
+ []
+ let writeByJsonPathOrdered tableName writer jsonPath orderFields =
+ WithProps.Json.writeByJsonPathOrdered tableName writer jsonPath orderFields (fromDataSource ())
+
+ /// Retrieve the first JSON document matching JSON field comparisons (->> =, etc.)
+ /// The table from which a document should be retrieved (may include schema)
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ /// The first matching JSON document if found, an empty JSON document otherwise
+ []
+ let firstByFields tableName howMatched fields =
+ WithProps.Json.firstByFields tableName howMatched fields (fromDataSource ())
+
+ ///
+ /// Write the first JSON document to the given StreamWriter matching JSON field comparisons
+ /// (->> =, etc.)
+ ///
+ /// The table from which a document should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ []
+ let writeFirstByFields tableName writer howMatched fields =
+ WithProps.Json.writeFirstByFields tableName writer howMatched fields (fromDataSource ())
+
+ ///
+ /// Retrieve the first JSON document matching JSON field comparisons (->> =, etc.) ordered by the given
+ /// fields in the document
+ ///
+ /// The table from which a document should be retrieved (may include schema)
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ /// Fields by which the results should be ordered
+ /// The first matching JSON document if found, an empty JSON document otherwise
+ []
+ let firstByFieldsOrdered tableName howMatched queryFields orderFields =
+ WithProps.Json.firstByFieldsOrdered tableName howMatched queryFields orderFields (fromDataSource ())
+
+ ///
+ /// Write the first JSON document to the given StreamWriter matching JSON field comparisons
+ /// (->> =, etc.) ordered by the given fields in the document
+ ///
+ /// The table from which a document should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// Whether to match any or all of the field conditions
+ /// The field conditions to match
+ /// Fields by which the results should be ordered
+ []
+ let writeFirstByFieldsOrdered tableName writer howMatched queryFields orderFields =
+ WithProps.Json.writeFirstByFieldsOrdered tableName writer howMatched queryFields orderFields (fromDataSource ())
+
+ /// Retrieve the first JSON document matching a JSON containment query (@>)
+ /// The table from which a document should be retrieved (may include schema)
+ /// The document to match with the containment query
+ /// The first matching JSON document if found, an empty JSON document otherwise
+ []
+ let firstByContains tableName (criteria: obj) =
+ WithProps.Json.firstByContains tableName criteria (fromDataSource ())
+
+ ///
+ /// Write the first JSON document to the given StreamWriter matching a JSON containment query (@>)
+ ///
+ /// The table from which a document should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The document to match with the containment query
+ []
+ let writeFirstByContains tableName writer (criteria: obj) =
+ WithProps.Json.writeFirstByContains tableName writer criteria (fromDataSource ())
+
+ ///
+ /// Retrieve the first JSON document matching a JSON containment query (@>) ordered by the given fields in
+ /// the document
+ ///
+ /// The table from which a document should be retrieved (may include schema)
+ /// The document to match with the containment query
+ /// Fields by which the results should be ordered
+ /// The first matching JSON document if found, an empty JSON document otherwise
+ []
+ let firstByContainsOrdered tableName (criteria: obj) orderFields =
+ WithProps.Json.firstByContainsOrdered tableName criteria orderFields (fromDataSource ())
+
+ ///
+ /// Write the first JSON document to the given StreamWriter matching a JSON containment query (@>)
+ /// ordered by the given fields in the document
+ ///
+ /// The table from which a document should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The document to match with the containment query
+ /// Fields by which the results should be ordered
+ []
+ let writeFirstByContainsOrdered tableName writer (criteria: obj) orderFields =
+ WithProps.Json.writeFirstByContainsOrdered tableName writer criteria orderFields (fromDataSource ())
+
+ /// Retrieve the first JSON document matching a JSON Path match query (@?)
+ /// The table from which a document should be retrieved (may include schema)
+ /// The JSON Path expression to match
+ /// The first matching JSON document if found, an empty JSON document otherwise
+ []
+ let firstByJsonPath tableName jsonPath =
+ WithProps.Json.firstByJsonPath tableName jsonPath (fromDataSource ())
+
+ ///
+ /// Write the first JSON document to the given StreamWriter matching a JSON Path match query (@?)
+ ///
+ /// The table from which a document should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The JSON Path expression to match
+ []
+ let writeFirstByJsonPath tableName writer jsonPath =
+ WithProps.Json.writeFirstByJsonPath tableName writer jsonPath (fromDataSource ())
+
+ ///
+ /// Retrieve the first JSON document matching a JSON Path match query (@?) ordered by the given fields in the
+ /// document
+ ///
+ /// The table from which a document should be retrieved (may include schema)
+ /// The JSON Path expression to match
+ /// Fields by which the results should be ordered
+ /// The first matching JSON document if found, an empty JSON document otherwise
+ []
+ let firstByJsonPathOrdered tableName jsonPath orderFields =
+ WithProps.Json.firstByJsonPathOrdered tableName jsonPath orderFields (fromDataSource ())
+
+ ///
+ /// Write the first JSON document to the given StreamWriter matching a JSON Path match query (@?)
+ /// ordered by the given fields in the document
+ ///
+ /// The table from which a document should be retrieved (may include schema)
+ /// The StreamWriter to which the results should be written
+ /// The JSON Path expression to match
+ /// Fields by which the results should be ordered
+ []
+ let writeFirstByJsonPathOrdered tableName writer jsonPath orderFields =
+ WithProps.Json.writeFirstByJsonPathOrdered tableName writer jsonPath orderFields (fromDataSource ())
+
+
/// Commands to update documents
[]
module Update =
diff --git a/src/Postgres/Library.fs b/src/Postgres/Library.fs
index 97cb339..4b20b4a 100644
--- a/src/Postgres/Library.fs
+++ b/src/Postgres/Library.fs
@@ -2,7 +2,6 @@
open System.IO
open System.Text
-open Npgsql.FSharp
/// The type of index to generate for the document
[]
@@ -362,4 +361,3 @@ module Results =
/// The query from which JSON should be extracted
let WriteJsonArray(writer, mapFunc: System.Func, sqlProps) =
writeJsonArray writer mapFunc.Invoke sqlProps
-
\ No newline at end of file
diff --git a/src/Postgres/WithProps.fs b/src/Postgres/WithProps.fs
index fcb7360..249697a 100644
--- a/src/Postgres/WithProps.fs
+++ b/src/Postgres/WithProps.fs
@@ -37,7 +37,7 @@ module Custom =
/// Execute a query that returns a JSON array of results
/// The query to retrieve the results
/// Parameters to use for the query
- /// The mapping function between the document and the domain item
+ /// The mapping function to extract the document
/// The SqlProps to use to execute the query
/// A JSON array of results for the given query
[]
@@ -49,7 +49,7 @@ module Custom =
/// Execute a query that returns a JSON array of results
/// The query to retrieve the results
/// Parameters to use for the query
- /// The mapping function between the document and the domain item
+ /// The mapping function to extract the document
/// The SqlProps to use to execute the query
/// A JSON array of results for the given query
let JsonArray(query, parameters, mapFunc: System.Func, sqlProps) =
@@ -59,7 +59,7 @@ module Custom =
/// The query to retrieve the results
/// Parameters to use for the query
/// The StreamWriter to which the results should be written
- /// The mapping function between the document and the domain item
+ /// The mapping function to extract the document
/// The SqlProps to use to execute the query
[]
let writeJsonArray query parameters writer (mapFunc: RowReader -> string) sqlProps =
@@ -71,7 +71,7 @@ module Custom =
/// The query to retrieve the results
/// Parameters to use for the query
/// The StreamWriter to which the results should be written
- /// The mapping function between the document and the domain item
+ /// The mapping function to extract the document
/// The SqlProps to use to execute the query
let WriteJsonArray(query, parameters, writer, mapFunc: System.Func, sqlProps) =
writeJsonArray query parameters writer mapFunc.Invoke sqlProps
@@ -103,7 +103,7 @@ module Custom =
/// Execute a query that returns one or no JSON documents
/// The query to retrieve the results
/// Parameters to use for the query
- /// The mapping function between the document and the domain item
+ /// The mapping function to extract the document
/// The SqlProps to use to execute the query
/// The JSON document with the first matching result, or an empty document if not found
[]
@@ -114,7 +114,7 @@ module Custom =
/// Execute a query that returns one or no JSON documents
/// The query to retrieve the results
/// Parameters to use for the query
- /// The mapping function between the document and the domain item
+ /// The mapping function to extract the document
/// The SqlProps to use to execute the query
/// The JSON document with the first matching result, or an empty document if not found
let JsonSingle(query, parameters, mapFunc: System.Func, sqlProps) =
@@ -733,7 +733,6 @@ module Json =
/// The table from which documents should be retrieved (may include schema)
/// The StreamWriter to which the results should be written
/// The SqlProps to use to execute the query
- /// All documents from the given table as a JSON array
[]
let writeAll tableName writer sqlProps =
Custom.writeJsonArray (Query.find tableName) [] writer jsonFromData sqlProps
@@ -757,7 +756,6 @@ module Json =
/// The StreamWriter to which the results should be written
/// Fields by which the results should be ordered
/// The SqlProps to use to execute the query
- /// All documents from the given table as a JSON array, ordered by the given fields
[]
let writeAllOrdered tableName writer orderFields sqlProps =
Custom.writeJsonArray
@@ -902,7 +900,7 @@ module Json =
writer
jsonFromData
sqlProps
-
+
/// Retrieve JSON documents matching a JSON Path match query (@?)
/// The table from which documents should be retrieved (may include schema)
/// The JSON Path expression to match