namespace BitBadger.Documents.Sqlite open Microsoft.Data.Sqlite /// F# extensions for the SqliteConnection type [] module Extensions = type SqliteConnection with /// Execute a query that returns a list of results member conn.customList<'TDoc> query parameters mapFunc = WithConn.Custom.list<'TDoc> query parameters mapFunc conn /// Execute a query that returns one or no results member conn.customSingle<'TDoc> query parameters mapFunc = WithConn.Custom.single<'TDoc> query parameters mapFunc conn /// Execute a query that does not return a value member conn.customNonQuery query parameters = WithConn.Custom.nonQuery query parameters conn /// Execute a query that returns a scalar value member conn.customScalar<'T when 'T: struct> query parameters mapFunc = WithConn.Custom.scalar<'T> query parameters mapFunc conn /// Create a document table member conn.ensureTable name = WithConn.Definition.ensureTable name conn /// Create an index on a document table member conn.ensureIndex tableName indexName fields = WithConn.Definition.ensureIndex tableName indexName fields conn /// Insert a new document member conn.insert<'TDoc> tableName (document: 'TDoc) = WithConn.insert<'TDoc> tableName document conn /// Save a document, inserting it if it does not exist and updating it if it does (AKA "upsert") member conn.save<'TDoc> tableName (document: 'TDoc) = WithConn.save tableName document conn /// Count all documents in a table member conn.countAll tableName = WithConn.Count.all tableName conn /// Count matching documents using a comparison on a JSON field member conn.countByField tableName fieldName op (value: obj) = WithConn.Count.byField tableName fieldName op value conn /// Determine if a document exists for the given ID member conn.existsById tableName (docId: 'TKey) = WithConn.Exists.byId tableName docId conn /// Determine if a document exists using a comparison on a JSON field member conn.existsByField tableName fieldName op (value: obj) = WithConn.Exists.byField tableName fieldName op value conn /// Retrieve all documents in the given table member conn.findAll<'TDoc> tableName = WithConn.Find.all<'TDoc> tableName conn /// Retrieve a document by its ID member conn.findById<'TKey, 'TDoc> tableName (docId: 'TKey) = WithConn.Find.byId<'TKey, 'TDoc> tableName docId conn /// Retrieve documents via a comparison on a JSON field member conn.findByField<'TDoc> tableName fieldName op (value: obj) = WithConn.Find.byField<'TDoc> tableName fieldName op value conn /// Retrieve documents via a comparison on a JSON field, returning only the first result member conn.findFirstByField<'TDoc> tableName fieldName op (value: obj) = WithConn.Find.firstByField<'TDoc> tableName fieldName op value conn /// Update an entire document by its ID member conn.updateById tableName (docId: 'TKey) (document: 'TDoc) = WithConn.Update.byId tableName docId document conn /// Update an entire document by its ID, using the provided function to obtain the ID from the document member conn.updateByFunc tableName (idFunc: 'TDoc -> 'TKey) (document: 'TDoc) = WithConn.Update.byFunc tableName idFunc document conn /// Patch a document by its ID member conn.patchById tableName (docId: 'TKey) (patch: 'TPatch) = WithConn.Patch.byId tableName docId patch conn /// Patch documents using a comparison on a JSON field member conn.patchByField tableName fieldName op (value: obj) (patch: 'TPatch) = WithConn.Patch.byField tableName fieldName op value patch conn /// Delete a document by its ID member conn.deleteById tableName (docId: 'TKey) = WithConn.Delete.byId tableName docId conn /// Delete documents by matching a comparison on a JSON field member conn.deleteByField tableName fieldName op (value: obj) = WithConn.Delete.byField tableName fieldName op value conn open System.Runtime.CompilerServices /// C# extensions on the SqliteConnection type type SqliteConnectionCSharpExtensions = /// Execute a query that returns a list of results [] static member inline CustomList<'TDoc>(conn, query, parameters, mapFunc: System.Func) = WithConn.Custom.List<'TDoc>(query, parameters, mapFunc, conn) /// Execute a query that returns one or no results [] static member inline CustomSingle<'TDoc when 'TDoc: null>( conn, query, parameters, mapFunc: System.Func) = WithConn.Custom.Single<'TDoc>(query, parameters, mapFunc, conn) /// Execute a query that does not return a value [] static member inline CustomNonQuery(conn, query, parameters) = WithConn.Custom.nonQuery query parameters conn /// Execute a query that returns a scalar value [] static member inline CustomScalar<'T when 'T: struct>( conn, query, parameters, mapFunc: System.Func) = WithConn.Custom.Scalar<'T>(query, parameters, mapFunc, conn) /// Create a document table [] static member inline EnsureTable(conn, name) = WithConn.Definition.ensureTable name conn /// Create an index on one or more fields in a document table [] static member inline EnsureIndex(conn, tableName, indexName, fields) = WithConn.Definition.ensureIndex tableName indexName fields conn /// Insert a new document [] static member inline Insert<'TDoc>(conn, tableName, document: 'TDoc) = WithConn.insert<'TDoc> tableName document conn /// Save a document, inserting it if it does not exist and updating it if it does (AKA "upsert") [] static member inline Save<'TDoc>(conn, tableName, document: 'TDoc) = WithConn.save<'TDoc> tableName document conn /// Count all documents in a table [] static member inline CountAll(conn, tableName) = WithConn.Count.all tableName conn /// Count matching documents using a comparison on a JSON field [] static member inline CountByField(conn, tableName, fieldName, op, value: obj) = WithConn.Count.byField tableName fieldName op value conn /// Determine if a document exists for the given ID [] static member inline ExistsById<'TKey>(conn, tableName, docId: 'TKey) = WithConn.Exists.byId tableName docId conn /// Determine if a document exists using a comparison on a JSON field [] static member inline ExistsByField(conn, tableName, fieldName, op, value: obj) = WithConn.Exists.byField tableName fieldName op value conn /// Retrieve all documents in the given table [] static member inline FindAll<'TDoc>(conn, tableName) = WithConn.Find.All<'TDoc>(tableName, conn) /// Retrieve a document by its ID [] static member inline FindById<'TKey, 'TDoc when 'TDoc: null>(conn, tableName, docId: 'TKey) = WithConn.Find.ById<'TKey, 'TDoc>(tableName, docId, conn) /// Retrieve documents via a comparison on a JSON field [] static member inline FindByField<'TDoc>(conn, tableName, fieldName, op, value) = WithConn.Find.ByField<'TDoc>(tableName, fieldName, op, value, conn) /// Retrieve documents via a comparison on a JSON field, returning only the first result [] static member inline FindFirstByField<'TDoc when 'TDoc: null>(conn, tableName, fieldName, op, value: obj) = WithConn.Find.FirstByField<'TDoc>(tableName, fieldName, op, value, conn) /// Update an entire document by its ID [] static member inline UpdateById<'TKey, 'TDoc>(conn, tableName, docId: 'TKey, document: 'TDoc) = WithConn.Update.byId tableName docId document conn /// Update an entire document by its ID, using the provided function to obtain the ID from the document [] static member inline UpdateByFunc<'TKey, 'TDoc>(conn, tableName, idFunc: System.Func<'TDoc, 'TKey>, doc: 'TDoc) = WithConn.Update.ByFunc(tableName, idFunc, doc, conn) /// Patch a document by its ID [] static member inline PatchById<'TKey, 'TPatch>(conn, tableName, docId: 'TKey, patch: 'TPatch) = WithConn.Patch.byId tableName docId patch conn /// Patch documents using a comparison on a JSON field [] static member inline PatchByField<'TPatch>(conn, tableName, fieldName, op, value: obj, patch: 'TPatch) = WithConn.Patch.byField tableName fieldName op value patch conn /// Delete a document by its ID [] static member inline DeleteById<'TKey>(conn, tableName, docId: 'TKey) = WithConn.Delete.byId tableName docId conn /// Delete documents by matching a comparison on a JSON field [] static member inline DeleteByField(conn, tableName, fieldName, op, value: obj) = WithConn.Delete.byField tableName fieldName op value conn