Daniel J. Summers 3656bb384c Another interim commit
Home page and some post stuff written
2016-07-08 23:18:44 -05:00

22 lines
780 B
Forth

module myWebLog.Data.WebLog
open myWebLog.Entities
open Rethink
open RethinkDb.Driver
open RethinkDb.Driver.Net
let private r = RethinkDB.R
type PageList = { pageList : Ast.CoerceTo }
/// Detemine the web log by the URL base
let tryFindWebLogByUrlBase (conn : IConnection) (urlBase : string) =
r.Table(Table.WebLog).GetAll([| urlBase |]).OptArg("index", "urlBase")
.Merge(fun webLog -> { pageList = r.Table(Table.Page)
.GetAll([| webLog.["id"], true |]).OptArg("index", "pageList")
.OrderBy("title")
.Pluck([| "title", "permalink" |])
.CoerceTo("array") })
|> runCursorAsync<WebLog> conn
|> Seq.tryHead