Skip to content

Commit

Permalink
Sort Results
Browse files Browse the repository at this point in the history
  • Loading branch information
goetz-markgraf committed Oct 12, 2020
1 parent 6d286b7 commit d27fb34
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Server/Server.fs
Expand Up @@ -13,6 +13,9 @@ module Database =
let getAll () =
database

let getAllSorted () =
database |> List.sortBy (fun each -> each.Id)

let init() =
database <- [
{
Expand Down Expand Up @@ -62,13 +65,13 @@ module Todos =
let webApp =
router {
get Route.todos (fun next ctx ->
json (Database.getAll()) next ctx)
json (Database.getAllSorted()) next ctx)
post Route.todos (fun next ctx ->
task {
let! description = ctx.BindModelAsync<string>()
let model = Todos.addTodo (Database.getAll()) description
Database.save model
return! json model next ctx
return! json (Database.getAllSorted()) next ctx
})
}

Expand Down

0 comments on commit d27fb34

Please sign in to comment.