add db, user registering into db, format

This commit is contained in:
pena 2021-11-07 00:31:32 +01:00 committed by Swrup
parent 6c64dcfffd
commit 82e65cfad4
6 changed files with 91 additions and 40 deletions

13
src/db.ml Normal file
View file

@ -0,0 +1,13 @@
let db_root = App.data_dir
let () =
match Bos.OS.Dir.create (Fpath.v db_root) with
| Ok true -> Dream.log "created %s" db_root
| Ok false -> Dream.log "%s already exists" db_root
| Error (`Msg _) ->
Dream.warning (fun log -> log "error when creating %s" db_root)
let db = Filename.concat db_root "permap.db"
let with_db ?mode ?mutex ?cache ?vfs ?timeout f =
Sqlite3_utils.with_db ?mode ?mutex ?cache ?vfs ?timeout db f