v4.1 (#11)
- Add `Json` module to return JSON strings and write JSON as it's read to a `PipeWriter` - Add `docfx`-based documentation to allow how-to docs and API docs to be generated on the same site Reviewed-on: #11
This commit was merged in pull request #11.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -21,11 +21,45 @@ module Custom =
|
||||
let List<'TDoc>(query, parameters, mapFunc: System.Func<RowReader, 'TDoc>) =
|
||||
WithProps.Custom.List<'TDoc>(query, parameters, mapFunc, fromDataSource ())
|
||||
|
||||
/// <summary>Execute a query that returns a JSON array of results</summary>
|
||||
/// <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 to extract the document</param>
|
||||
/// <returns>A JSON array of results for the given query</returns>
|
||||
[<CompiledName "FSharpJsonArray">]
|
||||
let jsonArray query parameters mapFunc =
|
||||
WithProps.Custom.jsonArray query parameters mapFunc (fromDataSource ())
|
||||
|
||||
/// <summary>Execute a query that returns a JSON array of results</summary>
|
||||
/// <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 to extract the document</param>
|
||||
/// <returns>A JSON array of results for the given query</returns>
|
||||
let JsonArray(query, parameters, mapFunc) =
|
||||
WithProps.Custom.JsonArray(query, parameters, mapFunc, fromDataSource ())
|
||||
|
||||
/// <summary>Execute a query, writing its results to the given <c>PipeWriter</c></summary>
|
||||
/// <param name="query">The query to retrieve the results</param>
|
||||
/// <param name="parameters">Parameters to use for the query</param>
|
||||
/// <param name="writer">The PipeWriter to which the results should be written</param>
|
||||
/// <param name="mapFunc">The mapping function to extract the document</param>
|
||||
[<CompiledName "FSharpWriteJsonArray">]
|
||||
let writeJsonArray query parameters writer mapFunc =
|
||||
WithProps.Custom.writeJsonArray query parameters writer mapFunc (fromDataSource ())
|
||||
|
||||
/// <summary>Execute a query, writing its results to the given <c>PipeWriter</c></summary>
|
||||
/// <param name="query">The query to retrieve the results</param>
|
||||
/// <param name="parameters">Parameters to use for the query</param>
|
||||
/// <param name="writer">The PipeWriter to which the results should be written</param>
|
||||
/// <param name="mapFunc">The mapping function to extract the document</param>
|
||||
let WriteJsonArray(query, parameters, writer, mapFunc) =
|
||||
WithProps.Custom.WriteJsonArray(query, parameters, writer, mapFunc, fromDataSource ())
|
||||
|
||||
/// <summary>Execute a query that returns one or no results</summary>
|
||||
/// <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><tt>Some</tt> with the first matching result, or <tt>None</tt> if not found</returns>
|
||||
/// <returns><c>Some</c> with the first matching result, or <c>None</c> if not found</returns>
|
||||
[<CompiledName "FSharpSingle">]
|
||||
let single<'TDoc> query parameters (mapFunc: RowReader -> 'TDoc) =
|
||||
WithProps.Custom.single<'TDoc> query parameters mapFunc (fromDataSource ())
|
||||
@@ -34,11 +68,28 @@ module Custom =
|
||||
/// <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>
|
||||
/// <returns>The first matching result, or <c>null</c> if not found</returns>
|
||||
let Single<'TDoc when 'TDoc: null and 'TDoc: not struct>(
|
||||
query, parameters, mapFunc: System.Func<RowReader, 'TDoc>) =
|
||||
WithProps.Custom.Single<'TDoc>(query, parameters, mapFunc, fromDataSource ())
|
||||
|
||||
/// <summary>Execute a query that returns one or no JSON documents</summary>
|
||||
/// <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 to extract the document</param>
|
||||
/// <returns>The JSON document with the first matching result, or an empty document if not found</returns>
|
||||
[<CompiledName "FSharpJsonSingle">]
|
||||
let jsonSingle query parameters mapFunc =
|
||||
WithProps.Custom.jsonSingle query parameters mapFunc (fromDataSource ())
|
||||
|
||||
/// <summary>Execute a query that returns one or no JSON documents</summary>
|
||||
/// <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 to extract the document</param>
|
||||
/// <returns>The JSON document with the first matching result, or an empty document if not found</returns>
|
||||
let JsonSingle(query, parameters, mapFunc) =
|
||||
WithProps.Custom.JsonSingle(query, parameters, mapFunc, fromDataSource ())
|
||||
|
||||
/// <summary>Execute a query that returns no results</summary>
|
||||
/// <param name="query">The query to retrieve the results</param>
|
||||
/// <param name="parameters">Parameters to use for the query</param>
|
||||
@@ -120,7 +171,7 @@ module Count =
|
||||
let all tableName =
|
||||
WithProps.Count.all tableName (fromDataSource ())
|
||||
|
||||
/// <summary>Count matching documents using JSON field comparisons (<tt>->> =</tt>, etc.)</summary>
|
||||
/// <summary>Count matching documents using JSON field comparisons (<c>->> =</c>, etc.)</summary>
|
||||
/// <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>
|
||||
@@ -129,7 +180,7 @@ module Count =
|
||||
let byFields tableName howMatched fields =
|
||||
WithProps.Count.byFields tableName howMatched fields (fromDataSource ())
|
||||
|
||||
/// <summary>Count matching documents using a JSON containment query (<tt>@></tt>)</summary>
|
||||
/// <summary>Count matching documents using a JSON containment query (<c>@></c>)</summary>
|
||||
/// <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>
|
||||
@@ -137,7 +188,7 @@ module Count =
|
||||
let byContains tableName criteria =
|
||||
WithProps.Count.byContains tableName criteria (fromDataSource ())
|
||||
|
||||
/// <summary>Count matching documents using a JSON Path match query (<tt>@?</tt>)</summary>
|
||||
/// <summary>Count matching documents using a JSON Path match query (<c>@?</c>)</summary>
|
||||
/// <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>
|
||||
@@ -158,7 +209,7 @@ module Exists =
|
||||
let byId tableName docId =
|
||||
WithProps.Exists.byId tableName docId (fromDataSource ())
|
||||
|
||||
/// <summary>Determine if a document exists using JSON field comparisons (<tt>->> =</tt>, etc.)</summary>
|
||||
/// <summary>Determine if a document exists using JSON field comparisons (<c>->> =</c>, etc.)</summary>
|
||||
/// <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>
|
||||
@@ -167,7 +218,7 @@ module Exists =
|
||||
let byFields tableName howMatched fields =
|
||||
WithProps.Exists.byFields tableName howMatched fields (fromDataSource ())
|
||||
|
||||
/// <summary>Determine if a document exists using a JSON containment query (<tt>@></tt>)</summary>
|
||||
/// <summary>Determine if a document exists using a JSON containment query (<c>@></c>)</summary>
|
||||
/// <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>
|
||||
@@ -175,7 +226,7 @@ module Exists =
|
||||
let byContains tableName criteria =
|
||||
WithProps.Exists.byContains tableName criteria (fromDataSource ())
|
||||
|
||||
/// <summary>Determine if a document exists using a JSON Path match query (<tt>@?</tt>)</summary>
|
||||
/// <summary>Determine if a document exists using a JSON Path match query (<c>@?</c>)</summary>
|
||||
/// <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>
|
||||
@@ -184,7 +235,7 @@ module Exists =
|
||||
WithProps.Exists.byJsonPath tableName jsonPath (fromDataSource ())
|
||||
|
||||
|
||||
/// <summary>Commands to retrieve documents</summary>
|
||||
/// <summary>Commands to retrieve documents as domain objects</summary>
|
||||
[<RequireQualifiedAccess>]
|
||||
module Find =
|
||||
|
||||
@@ -219,7 +270,7 @@ module Find =
|
||||
/// <summary>Retrieve a document by its ID</summary>
|
||||
/// <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><tt>Some</tt> with the document if found, <tt>None</tt> otherwise</returns>
|
||||
/// <returns><c>Some</c> with the document if found, <c>None</c> otherwise</returns>
|
||||
[<CompiledName "FSharpById">]
|
||||
let byId<'TKey, 'TDoc> tableName docId =
|
||||
WithProps.Find.byId<'TKey, 'TDoc> tableName docId (fromDataSource ())
|
||||
@@ -227,11 +278,11 @@ module Find =
|
||||
/// <summary>Retrieve a document by its ID</summary>
|
||||
/// <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>
|
||||
/// <returns>The document if found, <c>null</c> otherwise</returns>
|
||||
let ById<'TKey, 'TDoc when 'TDoc: null and 'TDoc: not struct>(tableName, docId: 'TKey) =
|
||||
WithProps.Find.ById<'TKey, 'TDoc>(tableName, docId, fromDataSource ())
|
||||
|
||||
/// <summary>Retrieve documents matching JSON field comparisons (<tt>->> =</tt>, etc.)</summary>
|
||||
/// <summary>Retrieve documents matching JSON field comparisons (<c>->> =</c>, etc.)</summary>
|
||||
/// <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>
|
||||
@@ -240,7 +291,7 @@ module Find =
|
||||
let byFields<'TDoc> tableName howMatched fields =
|
||||
WithProps.Find.byFields<'TDoc> tableName howMatched fields (fromDataSource ())
|
||||
|
||||
/// <summary>Retrieve documents matching JSON field comparisons (<tt>->> =</tt>, etc.)</summary>
|
||||
/// <summary>Retrieve documents matching JSON field comparisons (<c>->> =</c>, etc.)</summary>
|
||||
/// <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>
|
||||
@@ -249,8 +300,8 @@ module Find =
|
||||
WithProps.Find.ByFields<'TDoc>(tableName, howMatched, fields, fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve documents matching JSON field comparisons (<tt>->> =</tt>, etc.) ordered by the given fields in
|
||||
/// the document
|
||||
/// Retrieve documents matching JSON field comparisons (<c>->> =</c>, etc.) ordered by the given fields in the
|
||||
/// document
|
||||
/// </summary>
|
||||
/// <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>
|
||||
@@ -262,8 +313,8 @@ module Find =
|
||||
WithProps.Find.byFieldsOrdered<'TDoc> tableName howMatched queryFields orderFields (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve documents matching JSON field comparisons (<tt>->> =</tt>, etc.) ordered by the given fields in
|
||||
/// the document
|
||||
/// Retrieve documents matching JSON field comparisons (<c>->> =</c>, etc.) ordered by the given fields in the
|
||||
/// document
|
||||
/// </summary>
|
||||
/// <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>
|
||||
@@ -273,7 +324,7 @@ module Find =
|
||||
let ByFieldsOrdered<'TDoc>(tableName, howMatched, queryFields, orderFields) =
|
||||
WithProps.Find.ByFieldsOrdered<'TDoc>(tableName, howMatched, queryFields, orderFields, fromDataSource ())
|
||||
|
||||
/// <summary>Retrieve documents matching a JSON containment query (<tt>@></tt>)</summary>
|
||||
/// <summary>Retrieve documents matching a JSON containment query (<c>@></c>)</summary>
|
||||
/// <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>
|
||||
@@ -281,7 +332,7 @@ module Find =
|
||||
let byContains<'TDoc> tableName (criteria: obj) =
|
||||
WithProps.Find.byContains<'TDoc> tableName criteria (fromDataSource ())
|
||||
|
||||
/// <summary>Retrieve documents matching a JSON containment query (<tt>@></tt>)</summary>
|
||||
/// <summary>Retrieve documents matching a JSON containment query (<c>@></c>)</summary>
|
||||
/// <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>
|
||||
@@ -289,8 +340,7 @@ module Find =
|
||||
WithProps.Find.ByContains<'TDoc>(tableName, criteria, fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve documents matching a JSON containment query (<tt>@></tt>) ordered by the given fields in the
|
||||
/// document
|
||||
/// Retrieve documents matching a JSON containment query (<c>@></c>) ordered by the given fields in the document
|
||||
/// </summary>
|
||||
/// <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>
|
||||
@@ -301,8 +351,7 @@ module Find =
|
||||
WithProps.Find.byContainsOrdered<'TDoc> tableName criteria orderFields (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve documents matching a JSON containment query (<tt>@></tt>) ordered by the given fields in the
|
||||
/// document
|
||||
/// Retrieve documents matching a JSON containment query (<c>@></c>) ordered by the given fields in the document
|
||||
/// </summary>
|
||||
/// <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>
|
||||
@@ -311,7 +360,7 @@ module Find =
|
||||
let ByContainsOrdered<'TDoc>(tableName, criteria: obj, orderFields) =
|
||||
WithProps.Find.ByContainsOrdered<'TDoc>(tableName, criteria, orderFields, fromDataSource ())
|
||||
|
||||
/// <summary>Retrieve documents matching a JSON Path match query (<tt>@?</tt>)</summary>
|
||||
/// <summary>Retrieve documents matching a JSON Path match query (<c>@?</c>)</summary>
|
||||
/// <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>
|
||||
@@ -319,7 +368,7 @@ module Find =
|
||||
let byJsonPath<'TDoc> tableName jsonPath =
|
||||
WithProps.Find.byJsonPath<'TDoc> tableName jsonPath (fromDataSource ())
|
||||
|
||||
/// <summary>Retrieve documents matching a JSON Path match query (<tt>@?</tt>)</summary>
|
||||
/// <summary>Retrieve documents matching a JSON Path match query (<c>@?</c>)</summary>
|
||||
/// <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>
|
||||
@@ -327,7 +376,7 @@ module Find =
|
||||
WithProps.Find.ByJsonPath<'TDoc>(tableName, jsonPath, fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve documents matching a JSON Path match query (<tt>@?</tt>) ordered by the given fields in the document
|
||||
/// Retrieve documents matching a JSON Path match query (<c>@?</c>) ordered by the given fields in the document
|
||||
/// </summary>
|
||||
/// <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>
|
||||
@@ -338,7 +387,7 @@ module Find =
|
||||
WithProps.Find.byJsonPathOrdered<'TDoc> tableName jsonPath orderFields (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve documents matching a JSON Path match query (<tt>@?</tt>) ordered by the given fields in the document
|
||||
/// Retrieve documents matching a JSON Path match query (<c>@?</c>) ordered by the given fields in the document
|
||||
/// </summary>
|
||||
/// <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>
|
||||
@@ -347,132 +396,442 @@ module Find =
|
||||
let ByJsonPathOrdered<'TDoc>(tableName, jsonPath, orderFields) =
|
||||
WithProps.Find.ByJsonPathOrdered<'TDoc>(tableName, jsonPath, orderFields, fromDataSource ())
|
||||
|
||||
/// <summary>Retrieve the first document matching JSON field comparisons (<tt>->> =</tt>, etc.)</summary>
|
||||
/// <summary>Retrieve the first document matching JSON field comparisons (<c>->> =</c>, etc.)</summary>
|
||||
/// <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><tt>Some</tt> with the first document, or <tt>None</tt> if not found</returns>
|
||||
/// <returns><c>Some</c> with the first document, or <c>None</c> if not found</returns>
|
||||
[<CompiledName "FSharpFirstByFields">]
|
||||
let firstByFields<'TDoc> tableName howMatched fields =
|
||||
WithProps.Find.firstByFields<'TDoc> tableName howMatched fields (fromDataSource ())
|
||||
|
||||
/// <summary>Retrieve the first document matching JSON field comparisons (<tt>->> =</tt>, etc.)</summary>
|
||||
/// <summary>Retrieve the first document matching JSON field comparisons (<c>->> =</c>, etc.)</summary>
|
||||
/// <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>
|
||||
/// <returns>The first document, or <c>null</c> if not found</returns>
|
||||
let FirstByFields<'TDoc when 'TDoc: null and 'TDoc: not struct>(tableName, howMatched, fields) =
|
||||
WithProps.Find.FirstByFields<'TDoc>(tableName, howMatched, fields, fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the first document matching JSON field comparisons (<tt>->> =</tt>, etc.) ordered by the given
|
||||
/// Retrieve the first document matching JSON field comparisons (<c>->> =</c>, etc.) ordered by the given
|
||||
/// fields in the document
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <tt>Some</tt> with the first document ordered by the given fields, or <tt>None</tt> if not found
|
||||
/// </returns>
|
||||
/// <returns><c>Some</c> with the first document ordered by the given fields, or <c>None</c> if not found</returns>
|
||||
[<CompiledName "FSharpFirstByFieldsOrdered">]
|
||||
let firstByFieldsOrdered<'TDoc> tableName howMatched queryFields orderFields =
|
||||
WithProps.Find.firstByFieldsOrdered<'TDoc> tableName howMatched queryFields orderFields (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the first document matching JSON field comparisons (<tt>->> =</tt>, etc.) ordered by the given
|
||||
/// Retrieve the first document matching JSON field comparisons (<c>->> =</c>, etc.) ordered by the given
|
||||
/// fields in the document
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <returns>The first document ordered by the given fields, or <c>null</c> if not found</returns>
|
||||
let FirstByFieldsOrdered<'TDoc when 'TDoc: null and 'TDoc: not struct>(
|
||||
tableName, howMatched, queryFields, orderFields) =
|
||||
WithProps.Find.FirstByFieldsOrdered<'TDoc>(tableName, howMatched, queryFields, orderFields, fromDataSource ())
|
||||
|
||||
/// <summary>Retrieve the first document matching a JSON containment query (<tt>@></tt>)</summary>
|
||||
/// <summary>Retrieve the first document matching a JSON containment query (<c>@></c>)</summary>
|
||||
/// <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><tt>Some</tt> with the first document, or <tt>None</tt> if not found</returns>
|
||||
/// <returns><c>Some</c> with the first document, or <c>None</c> if not found</returns>
|
||||
[<CompiledName "FSharpFirstByContains">]
|
||||
let firstByContains<'TDoc> tableName (criteria: obj) =
|
||||
WithProps.Find.firstByContains<'TDoc> tableName criteria (fromDataSource ())
|
||||
|
||||
/// <summary>Retrieve the first document matching a JSON containment query (<tt>@></tt>)</summary>
|
||||
/// <summary>Retrieve the first document matching a JSON containment query (<c>@></c>)</summary>
|
||||
/// <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>
|
||||
/// <returns>The first document, or <c>null</c> if not found</returns>
|
||||
let FirstByContains<'TDoc when 'TDoc: null and 'TDoc: not struct>(tableName, criteria: obj) =
|
||||
WithProps.Find.FirstByContains<'TDoc>(tableName, criteria, fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the first document matching a JSON containment query (<tt>@></tt>) ordered by the given fields in
|
||||
/// the document
|
||||
/// Retrieve the first document matching a JSON containment query (<c>@></c>) ordered by the given fields in the
|
||||
/// document
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <tt>Some</tt> with the first document ordered by the given fields, or <tt>None</tt> if not found
|
||||
/// </returns>
|
||||
/// <returns><c>Some</c> with the first document ordered by the given fields, or <c>None</c> if not found</returns>
|
||||
[<CompiledName "FSharpFirstByContainsOrdered">]
|
||||
let firstByContainsOrdered<'TDoc> tableName (criteria: obj) orderFields =
|
||||
WithProps.Find.firstByContainsOrdered<'TDoc> tableName criteria orderFields (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the first document matching a JSON containment query (<tt>@></tt>) ordered by the given fields in
|
||||
/// the document
|
||||
/// Retrieve the first document matching a JSON containment query (<c>@></c>) ordered by the given fields in the
|
||||
/// document
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <returns>The first document ordered by the given fields, or <c>null</c> if not found</returns>
|
||||
let FirstByContainsOrdered<'TDoc when 'TDoc: null and 'TDoc: not struct>(tableName, criteria: obj, orderFields) =
|
||||
WithProps.Find.FirstByContainsOrdered<'TDoc>(tableName, criteria, orderFields, fromDataSource ())
|
||||
|
||||
/// <summary>Retrieve the first document matching a JSON Path match query (<tt>@?</tt>)</summary>
|
||||
/// <summary>Retrieve the first document matching a JSON Path match query (<c>@?</c>)</summary>
|
||||
/// <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><tt>Some</tt> with the first document, or <tt>None</tt> if not found</returns>
|
||||
/// <returns><c>Some</c> with the first document, or <c>None</c> if not found</returns>
|
||||
[<CompiledName "FSharpFirstByJsonPath">]
|
||||
let firstByJsonPath<'TDoc> tableName jsonPath =
|
||||
WithProps.Find.firstByJsonPath<'TDoc> tableName jsonPath (fromDataSource ())
|
||||
|
||||
/// <summary>Retrieve the first document matching a JSON Path match query (<tt>@?</tt>)</summary>
|
||||
/// <summary>Retrieve the first document matching a JSON Path match query (<c>@?</c>)</summary>
|
||||
/// <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>
|
||||
/// <returns>The first document, or <c>null</c> if not found</returns>
|
||||
let FirstByJsonPath<'TDoc when 'TDoc: null and 'TDoc: not struct>(tableName, jsonPath) =
|
||||
WithProps.Find.FirstByJsonPath<'TDoc>(tableName, jsonPath, fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the first document matching a JSON Path match query (<tt>@?</tt>) ordered by the given fields in the
|
||||
/// Retrieve the first document matching a JSON Path match query (<c>@?</c>) ordered by the given fields in the
|
||||
/// document
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <tt>Some</tt> with the first document ordered by the given fields, or <tt>None</tt> if not found
|
||||
/// </returns>
|
||||
/// <returns><c>Some</c> with the first document ordered by the given fields, or <c>None</c> if not found</returns>
|
||||
[<CompiledName "FSharpFirstByJsonPathOrdered">]
|
||||
let firstByJsonPathOrdered<'TDoc> tableName jsonPath orderFields =
|
||||
WithProps.Find.firstByJsonPathOrdered<'TDoc> tableName jsonPath orderFields (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the first document matching a JSON Path match query (<tt>@?</tt>) ordered by the given fields in the
|
||||
/// Retrieve the first document matching a JSON Path match query (<c>@?</c>) ordered by the given fields in the
|
||||
/// document
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <returns>The first document ordered by the given fields, or <c>null</c> if not found</returns>
|
||||
let FirstByJsonPathOrdered<'TDoc when 'TDoc: null and 'TDoc: not struct>(tableName, jsonPath, orderFields) =
|
||||
WithProps.Find.FirstByJsonPathOrdered<'TDoc>(tableName, jsonPath, orderFields, fromDataSource ())
|
||||
|
||||
|
||||
/// <summary>Commands to retrieve documents as JSON</summary>
|
||||
[<RequireQualifiedAccess>]
|
||||
module Json =
|
||||
|
||||
/// <summary>Retrieve all documents in the given table as a JSON array</summary>
|
||||
/// <param name="tableName">The table from which documents should be retrieved (may include schema)</param>
|
||||
/// <returns>All documents from the given table as a JSON array</returns>
|
||||
[<CompiledName "All">]
|
||||
let all tableName =
|
||||
WithProps.Json.all tableName (fromDataSource ())
|
||||
|
||||
/// <summary>Write all documents in the given table to the given <c>PipeWriter</c></summary>
|
||||
/// <param name="tableName">The table from which documents should be retrieved (may include schema)</param>
|
||||
/// <param name="writer">The PipeWriter to which the results should be written</param>
|
||||
[<CompiledName "WriteAll">]
|
||||
let writeAll tableName writer =
|
||||
WithProps.Json.writeAll tableName writer (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve all documents in the given table as a JSON array, ordered by the given fields in the document
|
||||
/// </summary>
|
||||
/// <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 as a JSON array, ordered by the given fields</returns>
|
||||
[<CompiledName "AllOrdered">]
|
||||
let allOrdered tableName orderFields =
|
||||
WithProps.Json.allOrdered tableName orderFields (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Write all documents in the given table to the given <c>PipeWriter</c>, ordered by the given fields in the
|
||||
/// document
|
||||
/// </summary>
|
||||
/// <param name="tableName">The table from which documents should be retrieved (may include schema)</param>
|
||||
/// <param name="writer">The PipeWriter to which the results should be written</param>
|
||||
/// <param name="orderFields">Fields by which the results should be ordered</param>
|
||||
[<CompiledName "WriteAllOrdered">]
|
||||
let writeAllOrdered tableName writer orderFields =
|
||||
WithProps.Json.writeAllOrdered tableName writer orderFields (fromDataSource ())
|
||||
|
||||
/// <summary>Retrieve a JSON document by its ID</summary>
|
||||
/// <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 JSON document if found, an empty JSON document otherwise</returns>
|
||||
[<CompiledName "ById">]
|
||||
let byId<'TKey> tableName (docId: 'TKey) =
|
||||
WithProps.Json.byId tableName docId (fromDataSource ())
|
||||
|
||||
/// <summary>Write a JSON document to the given <c>PipeWriter</c> by its ID</summary>
|
||||
/// <param name="tableName">The table from which a document should be retrieved (may include schema)</param>
|
||||
/// <param name="writer">The PipeWriter to which the results should be written</param>
|
||||
/// <param name="docId">The ID of the document to retrieve</param>
|
||||
[<CompiledName "WriteById">]
|
||||
let writeById<'TKey> tableName writer (docId: 'TKey) =
|
||||
WithProps.Json.writeById tableName writer docId (fromDataSource ())
|
||||
|
||||
/// <summary>Retrieve JSON documents matching JSON field comparisons (<c>->> =</c>, etc.)</summary>
|
||||
/// <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 JSON documents matching the given fields</returns>
|
||||
[<CompiledName "ByFields">]
|
||||
let byFields tableName howMatched fields =
|
||||
WithProps.Json.byFields tableName howMatched fields (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Write JSON documents to the given <c>PipeWriter</c> matching JSON field comparisons (<c>->> =</c>, etc.)
|
||||
/// </summary>
|
||||
/// <param name="tableName">The table from which documents should be retrieved (may include schema)</param>
|
||||
/// <param name="writer">The PipeWriter to which the results should be written</param>
|
||||
/// <param name="howMatched">Whether to match any or all of the field conditions</param>
|
||||
/// <param name="fields">The field conditions to match</param>
|
||||
[<CompiledName "WriteByFields">]
|
||||
let writeByFields tableName writer howMatched fields =
|
||||
WithProps.Json.writeByFields tableName writer howMatched fields (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve JSON documents matching JSON field comparisons (<c>->> =</c>, etc.) ordered by the given fields
|
||||
/// in the document
|
||||
/// </summary>
|
||||
/// <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 JSON documents matching the given fields, ordered by the other given fields</returns>
|
||||
[<CompiledName "ByFieldsOrdered">]
|
||||
let byFieldsOrdered tableName howMatched queryFields orderFields =
|
||||
WithProps.Json.byFieldsOrdered tableName howMatched queryFields orderFields (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Write JSON documents to the given <c>PipeWriter</c> matching JSON field comparisons (<c>->> =</c>, etc.)
|
||||
/// ordered by the given fields in the document
|
||||
/// </summary>
|
||||
/// <param name="tableName">The table from which documents should be retrieved (may include schema)</param>
|
||||
/// <param name="writer">The PipeWriter to which the results should be written</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>
|
||||
[<CompiledName "WriteByFieldsOrdered">]
|
||||
let writeByFieldsOrdered tableName writer howMatched queryFields orderFields =
|
||||
WithProps.Json.writeByFieldsOrdered tableName writer howMatched queryFields orderFields (fromDataSource ())
|
||||
|
||||
/// <summary>Retrieve JSON documents matching a JSON containment query (<c>@></c>)</summary>
|
||||
/// <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 JSON documents matching the given containment query</returns>
|
||||
[<CompiledName "ByContains">]
|
||||
let byContains tableName (criteria: obj) =
|
||||
WithProps.Json.byContains tableName criteria (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Write JSON documents to the given <c>PipeWriter</c> matching a JSON containment query (<c>@></c>)
|
||||
/// </summary>
|
||||
/// <param name="tableName">The table from which documents should be retrieved (may include schema)</param>
|
||||
/// <param name="writer">The PipeWriter to which the results should be written</param>
|
||||
/// <param name="criteria">The document to match with the containment query</param>
|
||||
[<CompiledName "WriteByContains">]
|
||||
let writeByContains tableName writer (criteria: obj) =
|
||||
WithProps.Json.writeByContains tableName writer criteria (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve JSON documents matching a JSON containment query (<c>@></c>) ordered by the given fields in the
|
||||
/// document
|
||||
/// </summary>
|
||||
/// <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>
|
||||
[<CompiledName "ByContainsOrdered">]
|
||||
let byContainsOrdered tableName (criteria: obj) orderFields =
|
||||
WithProps.Json.byContainsOrdered tableName criteria orderFields (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Write JSON documents to the given <c>PipeWriter</c> matching a JSON containment query (<c>@></c>) ordered by
|
||||
/// the given fields in the document
|
||||
/// </summary>
|
||||
/// <param name="tableName">The table from which documents should be retrieved (may include schema)</param>
|
||||
/// <param name="writer">The PipeWriter to which the results should be written</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>
|
||||
[<CompiledName "WriteByContainsOrdered">]
|
||||
let writeByContainsOrdered tableName writer (criteria: obj) orderFields =
|
||||
WithProps.Json.writeByContainsOrdered tableName writer criteria orderFields (fromDataSource ())
|
||||
|
||||
/// <summary>Retrieve JSON documents matching a JSON Path match query (<c>@?</c>)</summary>
|
||||
/// <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 JSON documents matching the given JSON Path expression</returns>
|
||||
[<CompiledName "ByJsonPath">]
|
||||
let byJsonPath tableName jsonPath =
|
||||
WithProps.Json.byJsonPath tableName jsonPath (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Write JSON documents to the given <c>PipeWriter</c> matching a JSON Path match query (<c>@?</c>)
|
||||
/// </summary>
|
||||
/// <param name="tableName">The table from which documents should be retrieved (may include schema)</param>
|
||||
/// <param name="writer">The PipeWriter to which the results should be written</param>
|
||||
/// <param name="jsonPath">The JSON Path expression to match</param>
|
||||
[<CompiledName "WriteByJsonPath">]
|
||||
let writeByJsonPath tableName writer jsonPath =
|
||||
WithProps.Json.writeByJsonPath tableName writer jsonPath (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve JSON documents matching a JSON Path match query (<c>@?</c>) ordered by the given fields in the document
|
||||
/// </summary>
|
||||
/// <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 JSON documents matching the given JSON Path expression, ordered by the given fields</returns>
|
||||
[<CompiledName "ByJsonPathOrdered">]
|
||||
let byJsonPathOrdered tableName jsonPath orderFields =
|
||||
WithProps.Json.byJsonPathOrdered tableName jsonPath orderFields (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Write JSON documents to the given <c>PipeWriter</c> matching a JSON Path match query (<c>@?</c>) ordered by the
|
||||
/// given fields in the document
|
||||
/// </summary>
|
||||
/// <param name="tableName">The table from which documents should be retrieved (may include schema)</param>
|
||||
/// <param name="writer">The PipeWriter to which the results should be written</param>
|
||||
/// <param name="jsonPath">The JSON Path expression to match</param>
|
||||
/// <param name="orderFields">Fields by which the results should be ordered</param>
|
||||
[<CompiledName "WriteByJsonPathOrdered">]
|
||||
let writeByJsonPathOrdered tableName writer jsonPath orderFields =
|
||||
WithProps.Json.writeByJsonPathOrdered tableName writer jsonPath orderFields (fromDataSource ())
|
||||
|
||||
/// <summary>Retrieve the first JSON document matching JSON field comparisons (<c>->> =</c>, etc.)</summary>
|
||||
/// <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 matching JSON document if found, an empty JSON document otherwise</returns>
|
||||
[<CompiledName "FirstByFields">]
|
||||
let firstByFields tableName howMatched fields =
|
||||
WithProps.Json.firstByFields tableName howMatched fields (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Write the first JSON document to the given <c>PipeWriter</c> matching JSON field comparisons
|
||||
/// (<c>->> =</c>, etc.)
|
||||
/// </summary>
|
||||
/// <param name="tableName">The table from which a document should be retrieved (may include schema)</param>
|
||||
/// <param name="writer">The PipeWriter to which the results should be written</param>
|
||||
/// <param name="howMatched">Whether to match any or all of the field conditions</param>
|
||||
/// <param name="fields">The field conditions to match</param>
|
||||
[<CompiledName "WriteFirstByFields">]
|
||||
let writeFirstByFields tableName writer howMatched fields =
|
||||
WithProps.Json.writeFirstByFields tableName writer howMatched fields (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the first JSON document matching JSON field comparisons (<c>->> =</c>, etc.) ordered by the given
|
||||
/// fields in the document
|
||||
/// </summary>
|
||||
/// <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 matching JSON document if found, an empty JSON document otherwise</returns>
|
||||
[<CompiledName "FirstByFieldsOrdered">]
|
||||
let firstByFieldsOrdered tableName howMatched queryFields orderFields =
|
||||
WithProps.Json.firstByFieldsOrdered tableName howMatched queryFields orderFields (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Write the first JSON document to the given <c>PipeWriter</c> matching JSON field comparisons
|
||||
/// (<c>->> =</c>, etc.) ordered by the given fields in the document
|
||||
/// </summary>
|
||||
/// <param name="tableName">The table from which a document should be retrieved (may include schema)</param>
|
||||
/// <param name="writer">The PipeWriter to which the results should be written</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>
|
||||
[<CompiledName "WriteFirstByFieldsOrdered">]
|
||||
let writeFirstByFieldsOrdered tableName writer howMatched queryFields orderFields =
|
||||
WithProps.Json.writeFirstByFieldsOrdered tableName writer howMatched queryFields orderFields (fromDataSource ())
|
||||
|
||||
/// <summary>Retrieve the first JSON document matching a JSON containment query (<c>@></c>)</summary>
|
||||
/// <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 matching JSON document if found, an empty JSON document otherwise</returns>
|
||||
[<CompiledName "FirstByContains">]
|
||||
let firstByContains tableName (criteria: obj) =
|
||||
WithProps.Json.firstByContains tableName criteria (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Write the first JSON document to the given <c>PipeWriter</c> matching a JSON containment query (<c>@></c>)
|
||||
/// </summary>
|
||||
/// <param name="tableName">The table from which a document should be retrieved (may include schema)</param>
|
||||
/// <param name="writer">The PipeWriter to which the results should be written</param>
|
||||
/// <param name="criteria">The document to match with the containment query</param>
|
||||
[<CompiledName "WriteFirstByContains">]
|
||||
let writeFirstByContains tableName writer (criteria: obj) =
|
||||
WithProps.Json.writeFirstByContains tableName writer criteria (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the first JSON document matching a JSON containment query (<c>@></c>) ordered by the given fields in
|
||||
/// the document
|
||||
/// </summary>
|
||||
/// <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 matching JSON document if found, an empty JSON document otherwise</returns>
|
||||
[<CompiledName "FirstByContainsOrdered">]
|
||||
let firstByContainsOrdered tableName (criteria: obj) orderFields =
|
||||
WithProps.Json.firstByContainsOrdered tableName criteria orderFields (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Write the first JSON document to the given <c>PipeWriter</c> matching a JSON containment query (<c>@></c>)
|
||||
/// ordered by the given fields in the document
|
||||
/// </summary>
|
||||
/// <param name="tableName">The table from which a document should be retrieved (may include schema)</param>
|
||||
/// <param name="writer">The PipeWriter to which the results should be written</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>
|
||||
[<CompiledName "WriteFirstByContainsOrdered">]
|
||||
let writeFirstByContainsOrdered tableName writer (criteria: obj) orderFields =
|
||||
WithProps.Json.writeFirstByContainsOrdered tableName writer criteria orderFields (fromDataSource ())
|
||||
|
||||
/// <summary>Retrieve the first JSON document matching a JSON Path match query (<c>@?</c>)</summary>
|
||||
/// <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 matching JSON document if found, an empty JSON document otherwise</returns>
|
||||
[<CompiledName "FirstByJsonPath">]
|
||||
let firstByJsonPath tableName jsonPath =
|
||||
WithProps.Json.firstByJsonPath tableName jsonPath (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Write the first JSON document to the given <c>PipeWriter</c> matching a JSON Path match query (<c>@?</c>)
|
||||
/// </summary>
|
||||
/// <param name="tableName">The table from which a document should be retrieved (may include schema)</param>
|
||||
/// <param name="writer">The PipeWriter to which the results should be written</param>
|
||||
/// <param name="jsonPath">The JSON Path expression to match</param>
|
||||
[<CompiledName "WriteFirstByJsonPath">]
|
||||
let writeFirstByJsonPath tableName writer jsonPath =
|
||||
WithProps.Json.writeFirstByJsonPath tableName writer jsonPath (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the first JSON document matching a JSON Path match query (<c>@?</c>) ordered by the given fields in the
|
||||
/// document
|
||||
/// </summary>
|
||||
/// <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 matching JSON document if found, an empty JSON document otherwise</returns>
|
||||
[<CompiledName "FirstByJsonPathOrdered">]
|
||||
let firstByJsonPathOrdered tableName jsonPath orderFields =
|
||||
WithProps.Json.firstByJsonPathOrdered tableName jsonPath orderFields (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Write the first JSON document to the given <c>PipeWriter</c> matching a JSON Path match query (<c>@?</c>)
|
||||
/// ordered by the given fields in the document
|
||||
/// </summary>
|
||||
/// <param name="tableName">The table from which a document should be retrieved (may include schema)</param>
|
||||
/// <param name="writer">The PipeWriter to which the results should be written</param>
|
||||
/// <param name="jsonPath">The JSON Path expression to match</param>
|
||||
/// <param name="orderFields">Fields by which the results should be ordered</param>
|
||||
[<CompiledName "WriteFirstByJsonPathOrdered">]
|
||||
let writeFirstByJsonPathOrdered tableName writer jsonPath orderFields =
|
||||
WithProps.Json.writeFirstByJsonPathOrdered tableName writer jsonPath orderFields (fromDataSource ())
|
||||
|
||||
|
||||
/// <summary>Commands to update documents</summary>
|
||||
[<RequireQualifiedAccess>]
|
||||
module Update =
|
||||
@@ -518,7 +877,7 @@ module Patch =
|
||||
WithProps.Patch.byId tableName docId patch (fromDataSource ())
|
||||
|
||||
/// <summary>
|
||||
/// Patch documents using a JSON field comparison query in the <tt>WHERE</tt> clause (<tt>->> =</tt>, etc.)
|
||||
/// Patch documents using a JSON field comparison query in the <c>WHERE</c> clause (<c>->> =</c>, etc.)
|
||||
/// </summary>
|
||||
/// <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>
|
||||
@@ -528,7 +887,7 @@ module Patch =
|
||||
let byFields tableName howMatched fields (patch: 'TPatch) =
|
||||
WithProps.Patch.byFields tableName howMatched fields patch (fromDataSource ())
|
||||
|
||||
/// <summary>Patch documents using a JSON containment query in the <tt>WHERE</tt> clause (<tt>@></tt>)</summary>
|
||||
/// <summary>Patch documents using a JSON containment query in the <c>WHERE</c> clause (<c>@></c>)</summary>
|
||||
/// <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>
|
||||
@@ -536,7 +895,7 @@ module Patch =
|
||||
let byContains tableName (criteria: 'TCriteria) (patch: 'TPatch) =
|
||||
WithProps.Patch.byContains tableName criteria patch (fromDataSource ())
|
||||
|
||||
/// <summary>Patch documents using a JSON Path match query in the <tt>WHERE</tt> clause (<tt>@?</tt>)</summary>
|
||||
/// <summary>Patch documents using a JSON Path match query in the <c>WHERE</c> clause (<c>@?</c>)</summary>
|
||||
/// <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>
|
||||
@@ -566,7 +925,7 @@ module RemoveFields =
|
||||
let byFields tableName howMatched fields fieldNames =
|
||||
WithProps.RemoveFields.byFields tableName howMatched fields fieldNames (fromDataSource ())
|
||||
|
||||
/// <summary>Remove fields from documents via a JSON containment query (<tt>@></tt>)</summary>
|
||||
/// <summary>Remove fields from documents via a JSON containment query (<c>@></c>)</summary>
|
||||
/// <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>
|
||||
@@ -574,7 +933,7 @@ module RemoveFields =
|
||||
let byContains tableName (criteria: 'TContains) fieldNames =
|
||||
WithProps.RemoveFields.byContains tableName criteria fieldNames (fromDataSource ())
|
||||
|
||||
/// <summary>Remove fields from documents via a JSON Path match query (<tt>@?</tt>)</summary>
|
||||
/// <summary>Remove fields from documents via a JSON Path match query (<c>@?</c>)</summary>
|
||||
/// <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>
|
||||
@@ -594,7 +953,7 @@ module Delete =
|
||||
let byId tableName (docId: 'TKey) =
|
||||
WithProps.Delete.byId tableName docId (fromDataSource ())
|
||||
|
||||
/// <summary>Delete documents by matching a JSON field comparison query (<tt>->> =</tt>, etc.)</summary>
|
||||
/// <summary>Delete documents by matching a JSON field comparison query (<c>->> =</c>, etc.)</summary>
|
||||
/// <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>
|
||||
@@ -602,7 +961,7 @@ module Delete =
|
||||
let byFields tableName howMatched fields =
|
||||
WithProps.Delete.byFields tableName howMatched fields (fromDataSource ())
|
||||
|
||||
/// <summary>Delete documents by matching a JSON contains query (<tt>@></tt>)</summary>
|
||||
/// <summary>Delete documents by matching a JSON contains query (<c>@></c>)</summary>
|
||||
/// <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>
|
||||
[<CompiledName "ByContains">]
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
[<Struct>]
|
||||
type DocumentIndex =
|
||||
|
||||
/// <summary>A <tt>GIN</tt> index with standard operations (all operators supported)</summary>
|
||||
/// <summary>A <c>GIN</c> index with standard operations (all operators supported)</summary>
|
||||
| Full
|
||||
|
||||
/// <summary>
|
||||
/// A <tt>GIN</tt> index with JSONPath operations (optimized for <tt>@></tt>, <tt>@?</tt>, <tt>@@</tt> operators)
|
||||
/// A <c>GIN</c> index with JSON Path operations (optimized for <c>@></c>, <c>@?</c>, <c>@@</c> operators)
|
||||
/// </summary>
|
||||
| Optimized
|
||||
|
||||
@@ -94,7 +94,7 @@ module Parameters =
|
||||
name, Sql.jsonb (Configuration.serializer().Serialize it)
|
||||
|
||||
/// <summary>Create JSON field parameters</summary>
|
||||
/// <param name="fields">The <tt>Field</tt>s to convert to parameters</param>
|
||||
/// <param name="fields">The <c>Field</c>s to convert to parameters</param>
|
||||
/// <param name="parameters">The current parameters for the query</param>
|
||||
/// <returns>A unified sequence of parameter names and values</returns>
|
||||
[<CompiledName "AddFields">]
|
||||
@@ -129,7 +129,7 @@ module Parameters =
|
||||
|
||||
/// <summary>Append JSON field name parameters for the given field names to the given parameters</summary>
|
||||
/// <param name="fieldNames">The names of fields to be addressed</param>
|
||||
/// <returns>The name (<tt>@name</tt>) and parameter value for the field names</returns>
|
||||
/// <returns>The name (<c>@name</c>) and parameter value for the field names</returns>
|
||||
[<CompiledName "FieldNames">]
|
||||
let fieldNameParams (fieldNames: string seq) =
|
||||
if Seq.length fieldNames = 1 then "@name", Sql.string (Seq.head fieldNames)
|
||||
@@ -145,12 +145,10 @@ module Parameters =
|
||||
[<RequireQualifiedAccess>]
|
||||
module Query =
|
||||
|
||||
/// <summary>
|
||||
/// Create a <tt>WHERE</tt> clause fragment to implement a comparison on fields in a JSON document
|
||||
/// </summary>
|
||||
/// <summary>Create a <c>WHERE</c> clause fragment to implement a comparison on fields in a JSON document</summary>
|
||||
/// <param name="howMatched">How the fields should be matched</param>
|
||||
/// <param name="fields">The fields for the comparisons</param>
|
||||
/// <returns>A <tt>WHERE</tt> clause implementing the comparisons for the given fields</returns>
|
||||
/// <returns>A <c>WHERE</c> clause implementing the comparisons for the given fields</returns>
|
||||
[<CompiledName "WhereByFields">]
|
||||
let whereByFields (howMatched: FieldMatch) fields =
|
||||
let name = ParameterName()
|
||||
@@ -179,9 +177,9 @@ module Query =
|
||||
else $"{it.Path PostgreSQL AsSql} {it.Comparison.OpSql} {param}")
|
||||
|> String.concat $" {howMatched} "
|
||||
|
||||
/// <summary>Create a <tt>WHERE</tt> clause fragment to implement an ID-based query</summary>
|
||||
/// <summary>Create a <c>WHERE</c> clause fragment to implement an ID-based query</summary>
|
||||
/// <param name="docId">The ID of the document</param>
|
||||
/// <returns>A <tt>WHERE</tt> clause fragment identifying a document by its ID</returns>
|
||||
/// <returns>A <c>WHERE</c> clause fragment identifying a document by its ID</returns>
|
||||
[<CompiledName "WhereById">]
|
||||
let whereById<'TKey> (docId: 'TKey) =
|
||||
whereByFields Any [ { Field.Equal (Configuration.idField ()) docId with ParameterName = Some "@id" } ]
|
||||
@@ -206,32 +204,28 @@ module Query =
|
||||
let tableName = name.Split '.' |> Array.last
|
||||
$"CREATE INDEX IF NOT EXISTS idx_{tableName}_document ON {name} USING GIN (data{extraOps})"
|
||||
|
||||
/// <summary>
|
||||
/// Create a <tt>WHERE</tt> clause fragment to implement a <tt>@></tt> (JSON contains) condition
|
||||
/// </summary>
|
||||
/// <summary>Create a <c>WHERE</c> clause fragment to implement a <c>@></c> (JSON contains) condition</summary>
|
||||
/// <param name="paramName">The parameter name for the query</param>
|
||||
/// <returns>A <tt>WHERE</tt> clause fragment for the contains condition</returns>
|
||||
/// <returns>A <c>WHERE</c> clause fragment for the contains condition</returns>
|
||||
[<CompiledName "WhereDataContains">]
|
||||
let whereDataContains paramName =
|
||||
$"data @> %s{paramName}"
|
||||
|
||||
/// <summary>
|
||||
/// Create a <tt>WHERE</tt> clause fragment to implement a <tt>@?</tt> (JSON Path match) condition
|
||||
/// </summary>
|
||||
/// <summary>Create a <c>WHERE</c> clause fragment to implement a <c>@?</c> (JSON Path match) condition</summary>
|
||||
/// <param name="paramName">The parameter name for the query</param>
|
||||
/// <returns>A <tt>WHERE</tt> clause fragment for the JSON Path match condition</returns>
|
||||
/// <returns>A <c>WHERE</c> clause fragment for the JSON Path match condition</returns>
|
||||
[<CompiledName "WhereJsonPathMatches">]
|
||||
let whereJsonPathMatches paramName =
|
||||
$"data @? %s{paramName}::jsonpath"
|
||||
|
||||
/// <summary>Create an <tt>UPDATE</tt> statement to patch documents</summary>
|
||||
/// <summary>Create an <c>UPDATE</c> statement to patch documents</summary>
|
||||
/// <param name="tableName">The table to be updated</param>
|
||||
/// <returns>A query to patch documents</returns>
|
||||
[<CompiledName "Patch">]
|
||||
let patch tableName =
|
||||
$"UPDATE %s{tableName} SET data = data || @data"
|
||||
|
||||
/// <summary>Create an <tt>UPDATE</tt> statement to remove fields from documents</summary>
|
||||
/// <summary>Create an <c>UPDATE</c> statement to remove fields from documents</summary>
|
||||
/// <param name="tableName">The table to be updated</param>
|
||||
/// <returns>A query to remove fields from documents</returns>
|
||||
[<CompiledName "RemoveFields">]
|
||||
@@ -270,6 +264,8 @@ module Query =
|
||||
Query.statementWhere statement (whereJsonPathMatches "@path")
|
||||
|
||||
|
||||
open System.Text
|
||||
|
||||
/// <summary>Functions for dealing with results</summary>
|
||||
[<AutoOpen>]
|
||||
module Results =
|
||||
@@ -289,16 +285,67 @@ module Results =
|
||||
let fromData<'T> row : 'T =
|
||||
fromDocument "data" row
|
||||
|
||||
/// <summary>Extract a count from the column <tt>it</tt></summary>
|
||||
/// <summary>Extract a count from the column <c>it</c></summary>
|
||||
/// <param name="row">A row reader set to the row with the count to retrieve</param>
|
||||
/// <returns>The count from the row</returns>
|
||||
[<CompiledName "ToCount">]
|
||||
let toCount (row: RowReader) =
|
||||
row.int "it"
|
||||
|
||||
/// <summary>Extract a true/false value from the column <tt>it</tt></summary>
|
||||
/// <summary>Extract a true/false value from the column <c>it</c></summary>
|
||||
/// <param name="row">A row reader set to the row with the true/false value to retrieve</param>
|
||||
/// <returns>The true/false value from the row</returns>
|
||||
[<CompiledName "ToExists">]
|
||||
let toExists (row: RowReader) =
|
||||
row.bool "it"
|
||||
|
||||
/// <summary>Extract a JSON document, specifying the field in which the document is found</summary>
|
||||
/// <param name="field">The field name containing the JSON document</param>
|
||||
/// <param name="row">A row reader set to the row with the document to be extracted</param>
|
||||
/// <returns>The JSON from the given field (an empty object if no field exists)</returns>
|
||||
[<CompiledName "JsonFromDocument">]
|
||||
let jsonFromDocument field (row: RowReader) =
|
||||
row.stringOrNone field |> Option.defaultValue "{}"
|
||||
|
||||
/// <summary>Extract a JSON document</summary>
|
||||
/// <param name="row">A row reader set to the row with the document to be extracted</param>
|
||||
/// <returns>The JSON from the row (an empty object if no field exists)</returns>
|
||||
[<CompiledName "JsonFromData">]
|
||||
let jsonFromData row =
|
||||
jsonFromDocument "data" row
|
||||
|
||||
/// <summary>Create a JSON array of items for the results of a query</summary>
|
||||
/// <param name="mapFunc">The mapping function to extract JSON from the query's results</param>
|
||||
/// <param name="sqlProps">The query from which JSON should be extracted</param>
|
||||
/// <returns>A JSON array as a string; no results will produce an empty array (<c>"[]"</c>)</returns>
|
||||
[<CompiledName "FSharpToJsonArray">]
|
||||
let toJsonArray (mapFunc: RowReader -> string) sqlProps = backgroundTask {
|
||||
let output = StringBuilder("[")
|
||||
do! sqlProps
|
||||
|> Sql.iterAsync (fun it ->
|
||||
if output.Length > 2 then ignore (output.Append ",")
|
||||
mapFunc it |> output.Append |> ignore)
|
||||
return output.Append("]").ToString()
|
||||
}
|
||||
|
||||
/// <summary>Create a JSON array of items for the results of a query</summary>
|
||||
/// <param name="mapFunc">The mapping function to extract JSON from the query's results</param>
|
||||
/// <param name="sqlProps">The query from which JSON should be extracted</param>
|
||||
/// <returns>A JSON array as a string; no results will produce an empty array (<c>"[]"</c>)</returns>
|
||||
let ToJsonArray(mapFunc: System.Func<RowReader, string>, sqlProps) =
|
||||
toJsonArray mapFunc.Invoke sqlProps
|
||||
|
||||
/// <summary>Write a JSON array of items for the results of a query to the given <c>PipeWriter</c></summary>
|
||||
/// <param name="writer">The PipeWriter to which results should be written</param>
|
||||
/// <param name="mapFunc">The mapping function to extract JSON from the query's results</param>
|
||||
/// <param name="sqlProps">The query from which JSON should be extracted</param>
|
||||
[<CompiledName "FSharpWriteJsonArray">]
|
||||
let writeJsonArray writer (mapFunc: RowReader -> string) sqlProps =
|
||||
sqlProps |> Sql.toSeq mapFunc |> PipeWriter.writeStrings writer
|
||||
|
||||
/// <summary>Write a JSON array of items for the results of a query to the given <c>PipeWriter</c></summary>
|
||||
/// <param name="writer">The PipeWriter to which results should be written</param>
|
||||
/// <param name="mapFunc">The mapping function to extract JSON from the query's results</param>
|
||||
/// <param name="sqlProps">The query from which JSON should be extracted</param>
|
||||
let WriteJsonArray(writer, mapFunc: System.Func<RowReader, string>, sqlProps) =
|
||||
writeJsonArray writer mapFunc.Invoke sqlProps
|
||||
|
||||
@@ -13,7 +13,7 @@ This package provides a lightweight document library backed by [PostgreSQL](http
|
||||
|
||||
## Upgrading from v3
|
||||
|
||||
There is a breaking API change for `ByField` (C#) / `byField` (F#), along with a compatibility namespace that can mitigate the impact of these changes. See [the migration guide](https://bitbadger.solutions/open-source/relational-documents/upgrade-from-v3-to-v4.html) for full details.
|
||||
There is a breaking API change for `ByField` (C#) / `byField` (F#), along with a compatibility namespace that can mitigate the impact of these changes. See [the migration guide](https://relationaldocs.bitbadger.solutions/dotnet/upgrade/v4.html) for full details.
|
||||
|
||||
## Getting Started
|
||||
|
||||
@@ -71,7 +71,7 @@ var customer = await Find.ById<string, Customer>("customer", "123");
|
||||
// Find.byId type signature is string -> 'TKey -> Task<'TDoc option>
|
||||
let! customer = Find.byId<string, Customer> "customer" "123"
|
||||
```
|
||||
_(keys are treated as strings or numbers depending on their defintion; however, they are indexed as strings)_
|
||||
_(keys are treated as strings or numbers depending on their definition; however, they are indexed as strings)_
|
||||
|
||||
Count customers in Atlanta (using JSON containment):
|
||||
|
||||
@@ -103,4 +103,4 @@ do! Delete.byJsonPath "customer" """$.City ? (@ == "Chicago")"""
|
||||
|
||||
## More Information
|
||||
|
||||
The [project site](https://bitbadger.solutions/open-source/relational-documents/) has full details on how to use this library.
|
||||
The [project site](https://relationaldocs.bitbadger.solutions/dotnet/) has full details on how to use this library.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user