Update to new doc library

Still need to remove deprecated calls
This commit is contained in:
2024-08-19 20:30:33 -04:00
parent f4be57b665
commit cd450a05e5
15 changed files with 83 additions and 63 deletions
@@ -2,6 +2,7 @@
open BitBadger.Documents
open BitBadger.Documents.Postgres
open BitBadger.Documents.Postgres.Compat
open Microsoft.Extensions.Logging
open MyWebLog
open MyWebLog.Data
@@ -19,7 +20,7 @@ type PostgresCategoryData(log: ILogger) =
let countTopLevel webLogId =
log.LogTrace "Category.countTopLevel"
Custom.scalar
$"""{Query.Count.byContains Table.Category}
$"""{Query.byContains (Query.count Table.Category)}
AND {Query.whereByField (Field.NEX (nameof Category.Empty.ParentId)) ""}"""
[ webLogContains webLogId ]
toCount
@@ -87,11 +88,11 @@ type PostgresCategoryData(log: ILogger) =
if hasChildren then
let childQuery, childParams =
if cat.ParentId.IsSome then
Query.Patch.byId Table.Category,
Query.byId (Query.patch Table.Category) "",
children
|> List.map (fun child -> [ idParam child.Id; jsonParam "@data" {| ParentId = cat.ParentId |} ])
else
Query.RemoveFields.byId Table.Category,
Query.byId (Query.removeFields Table.Category) "",
children
|> List.map (fun child ->
[ idParam child.Id; fieldNameParam [ nameof Category.Empty.ParentId ] ])
@@ -111,7 +112,7 @@ type PostgresCategoryData(log: ILogger) =
Configuration.dataSource ()
|> Sql.fromDataSource
|> Sql.executeTransactionAsync
[ Query.Patch.byId Table.Post,
[ Query.byId (Query.patch Table.Post) "",
posts
|> List.map (fun post ->
[ idParam post.Id