Update for v4-rc5 of doc library
This commit is contained in:
parent
0032d15c0a
commit
870f87cb17
|
@ -5,8 +5,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BitBadger.Documents.Postgres" Version="4.0.0-rc4" />
|
||||
<PackageReference Include="BitBadger.Documents.Sqlite" Version="4.0.0-rc4" />
|
||||
<PackageReference Include="BitBadger.Documents.Postgres" Version="4.0.0-rc5" />
|
||||
<PackageReference Include="BitBadger.Documents.Sqlite" Version="4.0.0-rc5" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.8" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
|
||||
|
|
|
@ -43,7 +43,6 @@ type PostgresCategoryData(log: ILogger) =
|
|||
|> Seq.filter (fun cat -> cat.ParentNames |> Array.contains it.Name)
|
||||
|> Seq.map _.Id
|
||||
|> Seq.append (Seq.singleton it.Id)
|
||||
|> Seq.map box
|
||||
|> Field.InArray (nameof Post.Empty.CategoryIds) Table.Post
|
||||
let query =
|
||||
(Query.statementWhere
|
||||
|
|
|
@ -111,8 +111,7 @@ type PostgresPageData(log: ILogger) =
|
|||
log.LogTrace "Page.findCurrentPermalink"
|
||||
if List.isEmpty permalinks then return None
|
||||
else
|
||||
let linkField =
|
||||
Field.InArray (nameof Page.Empty.PriorPermalinks) Table.Page (List.map (string >> box) permalinks)
|
||||
let linkField = Field.InArray (nameof Page.Empty.PriorPermalinks) Table.Page (List.map string permalinks)
|
||||
let query =
|
||||
(Query.statementWhere
|
||||
(Query.find Table.Page)
|
||||
|
|
|
@ -97,8 +97,7 @@ type PostgresPostData(log: ILogger) =
|
|||
log.LogTrace "Post.findCurrentPermalink"
|
||||
if List.isEmpty permalinks then return None
|
||||
else
|
||||
let linkField =
|
||||
Field.InArray (nameof Post.Empty.PriorPermalinks) Table.Post (List.map (string >> box) permalinks)
|
||||
let linkField = Field.InArray (nameof Post.Empty.PriorPermalinks) Table.Post (List.map string permalinks)
|
||||
let query =
|
||||
(Query.statementWhere
|
||||
(Query.find Table.Post)
|
||||
|
@ -121,7 +120,7 @@ type PostgresPostData(log: ILogger) =
|
|||
/// Get a page of categorized posts for the given web log (excludes revisions)
|
||||
let findPageOfCategorizedPosts webLogId (categoryIds: CategoryId list) pageNbr postsPerPage =
|
||||
log.LogTrace "Post.findPageOfCategorizedPosts"
|
||||
let catIdField = Field.InArray (nameof Post.Empty.CategoryIds) Table.Post (List.map (string >> box) categoryIds)
|
||||
let catIdField = Field.InArray (nameof Post.Empty.CategoryIds) Table.Post (List.map string categoryIds)
|
||||
Custom.list
|
||||
$"""{selectWithCriteria Table.Post}
|
||||
AND {Query.whereByFields All [ catIdField ]}
|
||||
|
|
|
@ -6,7 +6,6 @@ open Microsoft.Extensions.Logging
|
|||
open MyWebLog
|
||||
open MyWebLog.Data
|
||||
open Npgsql.FSharp
|
||||
open Npgsql.Internal.Postgres
|
||||
|
||||
/// PostgreSQL myWebLog tag mapping data implementation
|
||||
type PostgresTagMapData(log: ILogger) =
|
||||
|
@ -39,7 +38,7 @@ type PostgresTagMapData(log: ILogger) =
|
|||
/// Find any tag mappings in a list of tags for the given web log
|
||||
let findMappingForTags (tags: string list) webLogId =
|
||||
log.LogTrace "TagMap.findMappingForTags"
|
||||
let tagField = Field.InArray (nameof TagMap.Empty.Tag) Table.TagMap (List.map box tags)
|
||||
let tagField = Field.InArray (nameof TagMap.Empty.Tag) Table.TagMap tags
|
||||
Custom.list
|
||||
$"{selectWithCriteria Table.TagMap} AND {Query.whereByFields All [ tagField ]}"
|
||||
(addFieldParams [ tagField ] [ webLogContains webLogId ])
|
||||
|
|
|
@ -55,7 +55,7 @@ type PostgresWebLogUserData(log: ILogger) =
|
|||
/// Find the names of users by their IDs for the given web log
|
||||
let findNames webLogId (userIds: WebLogUserId list) = backgroundTask {
|
||||
log.LogTrace "WebLogUser.findNames"
|
||||
let idField = Field.In (nameof WebLogUser.Empty.Id) (List.map (string >> box) userIds)
|
||||
let idField = Field.In (nameof WebLogUser.Empty.Id) (List.map string userIds)
|
||||
let! users =
|
||||
Custom.list
|
||||
$"{selectWithCriteria Table.WebLogUser} AND {Query.whereByFields All [ idField ]}"
|
||||
|
|
|
@ -43,16 +43,14 @@ type SQLiteCategoryData(conn: SqliteConnection, ser: JsonSerializer, log: ILogge
|
|||
ordered
|
||||
|> Seq.map (fun it -> backgroundTask {
|
||||
// Parent category post counts include posts in subcategories
|
||||
let childCats =
|
||||
let childField =
|
||||
ordered
|
||||
|> Seq.filter (fun cat -> cat.ParentNames |> Array.contains it.Name)
|
||||
|> Seq.map _.Id
|
||||
|> Seq.append (Seq.singleton it.Id)
|
||||
|> Seq.map box
|
||||
|> Field.InArray (nameof Post.Empty.CategoryIds) Table.Post
|
||||
let fields =
|
||||
[ webLogField webLogId
|
||||
Field.Equal (nameof Post.Empty.Status) (string Published)
|
||||
Field.InArray (nameof Post.Empty.CategoryIds) Table.Post childCats ]
|
||||
[ webLogField webLogId; Field.Equal (nameof Post.Empty.Status) (string Published); childField ]
|
||||
let query =
|
||||
(Query.statementWhere (Query.count Table.Post) (Query.whereByFields All fields))
|
||||
.Replace("(*)", $"(DISTINCT data->>'{nameof Post.Empty.Id}')")
|
||||
|
|
|
@ -116,7 +116,7 @@ type SQLitePageData(conn: SqliteConnection, log: ILogger) =
|
|||
log.LogTrace "Page.findCurrentPermalink"
|
||||
let fields =
|
||||
[ webLogField webLogId
|
||||
Field.InArray (nameof Page.Empty.PriorPermalinks) Table.Page (List.map (string >> box) permalinks) ]
|
||||
Field.InArray (nameof Page.Empty.PriorPermalinks) Table.Page (List.map string permalinks) ]
|
||||
let query =
|
||||
(Query.statementWhere (Query.find Table.Page) (Query.whereByFields All fields))
|
||||
.Replace("SELECT data", $"SELECT data->>'{linkName}' AS permalink")
|
||||
|
|
|
@ -116,7 +116,7 @@ type SQLitePostData(conn: SqliteConnection, log: ILogger) =
|
|||
log.LogTrace "Post.findCurrentPermalink"
|
||||
let fields =
|
||||
[ webLogField webLogId
|
||||
Field.InArray (nameof Post.Empty.PriorPermalinks) Table.Post (List.map (string >> box) permalinks) ]
|
||||
Field.InArray (nameof Post.Empty.PriorPermalinks) Table.Post (List.map string permalinks) ]
|
||||
let query =
|
||||
(Query.statementWhere (Query.find Table.Post) (Query.whereByFields All fields))
|
||||
.Replace("SELECT data", $"SELECT data->>'{linkName}' AS permalink")
|
||||
|
@ -133,7 +133,7 @@ type SQLitePostData(conn: SqliteConnection, log: ILogger) =
|
|||
/// Get a page of categorized posts for the given web log (excludes revisions)
|
||||
let findPageOfCategorizedPosts webLogId (categoryIds: CategoryId list) pageNbr postsPerPage =
|
||||
log.LogTrace "Post.findPageOfCategorizedPosts"
|
||||
let catIdField = Field.InArray (nameof Post.Empty.CategoryIds) Table.Post (List.map (string >> box) categoryIds)
|
||||
let catIdField = Field.InArray (nameof Post.Empty.CategoryIds) Table.Post (List.map string categoryIds)
|
||||
conn.customList
|
||||
$"""{publishedPostByWebLog} AND {Query.whereByFields Any [ catIdField ]}
|
||||
{Query.orderBy [ Field.Named $"{publishName} DESC" ] SQLite}
|
||||
|
|
|
@ -39,8 +39,7 @@ type SQLiteTagMapData(conn: SqliteConnection, log: ILogger) =
|
|||
/// Find any tag mappings in a list of tags for the given web log
|
||||
let findMappingForTags (tags: string list) webLogId =
|
||||
log.LogTrace "TagMap.findMappingForTags"
|
||||
conn.findByFields<TagMap>
|
||||
Table.TagMap All [ webLogField webLogId; Field.In (nameof TagMap.Empty.Tag) (List.map box tags) ]
|
||||
conn.findByFields<TagMap> Table.TagMap All [ webLogField webLogId; Field.In (nameof TagMap.Empty.Tag) tags ]
|
||||
|
||||
/// Save a tag mapping
|
||||
let save (tagMap: TagMap) =
|
||||
|
|
|
@ -52,7 +52,7 @@ type SQLiteWebLogUserData(conn: SqliteConnection, log: ILogger) =
|
|||
/// Find the names of users by their IDs for the given web log
|
||||
let findNames webLogId (userIds: WebLogUserId list) =
|
||||
log.LogTrace "WebLogUser.findNames"
|
||||
let fields = [ webLogField webLogId; Field.In (nameof WebLogUser.Empty.Id) (List.map (string >> box) userIds) ]
|
||||
let fields = [ webLogField webLogId; Field.In (nameof WebLogUser.Empty.Id) (List.map string userIds) ]
|
||||
let query = Query.statementWhere (Query.find Table.WebLogUser) (Query.whereByFields All fields)
|
||||
conn.customList
|
||||
query
|
||||
|
|
Loading…
Reference in New Issue
Block a user