Convert to rc2 of doc lib

This commit is contained in:
2024-01-23 23:26:30 -05:00
parent 182b33ae79
commit 13994a29e7
11 changed files with 65 additions and 54 deletions

View File

@@ -81,15 +81,26 @@ type PostgresCategoryData(log: ILogger) =
let! children = Find.byContains<Category> Table.Category {| ParentId = catId |}
let hasChildren = not (List.isEmpty children)
if hasChildren then
let! _ =
Configuration.dataSource ()
|> Sql.fromDataSource
|> Sql.executeTransactionAsync
[ Query.Patch.byId Table.Category,
children
|> List.map (fun child ->
[ idParam child.Id; jsonParam "@data" {| ParentId = cat.ParentId |} ]) ]
()
if cat.ParentId.IsSome then
let! _ =
Configuration.dataSource ()
|> Sql.fromDataSource
|> Sql.executeTransactionAsync
[ Query.Patch.byId Table.Category,
children
|> List.map (fun child ->
[ idParam child.Id; jsonParam "@data" {| ParentId = cat.ParentId |} ]) ]
()
else
let! _ =
Configuration.dataSource ()
|> Sql.fromDataSource
|> Sql.executeTransactionAsync
[ Query.RemoveFields.byId Table.Category,
children
|> List.map (fun child ->
[ idParam child.Id; fieldNameParam [ nameof Category.Empty.ParentId ] ]) ]
()
// Delete the category off all posts where it is assigned
let! posts =
Custom.list