View on GitHub

SqlFun

Idiomatic data access for F#

Download this project as a .zip file Download this project as a tar.gz file

CRUD templates

SqlFun allows to generate CRUD commands from a record structure:

    let insertPost: Post -> AsyncDb<unit> = 
        sql <| Crud.Insert<Post> ["id"; "comments"; "tags"]

    let updatePost: Post -> AsyncDb<unit> = 
        sql <| Crud.Update<Post> (["id"], ["comments"; "tags"])

    let deletePost: int -> AsyncDb<unit> =
        sql <| Crud.DeleteByKey<Post> ["id"]

    let getPost: int -> AsyncDb<Post> = 
        sql <| Crud.SelectByKey<Post> ["id"]

By default, Insert and Update functions use all record fields, but it’s possible to exclude some of them. All functions except Insert require parameters specifying key columns.