[READ-ONLY] Mirror of https://github.com/Schniz/sapapa. A soothing CouchDB client for Reason and OCaml
couchdb couchdb-client ocaml reasonml
0

Configure Feed

Select the types of activity you want to include in your feed.

Reason 14.3%
Shell 0.1%
Dune 0.1%
Other 85.6%
16 2 0

Clone this repository

https://tangled.org/schlez.in/sapapa https://tangled.org/did:plc:5otsniqgvzkp427y6rfmena2
git@tangled.org:schlez.in/sapapa git@tangled.org:did:plc:5otsniqgvzkp427y6rfmena2

For self-hosted knots, clone URLs may differ based on your setup.



README.md

Sapapa 😌#

Build Status

A soothing CouchDB client for native Reason and OCaml. Just Relax. 😌

Under the hood, it calmly leverages Yojson for JSON parsing and Lwt for non-blocking I/O. Every API call returns a result type which has a strongly-typed error in return, so you know exactly what failed, in order to build safer apps.

In the future, we may want to support different JSON engines and async libraries (like Jane Street's Async), but for now, this gives a fast and safe environment.

The state of mind behind this library is that you can get Client can give you a reference to a Database, whether it exists or not, and a Database can give you a reference to a Document, whether it exists or not:

let client =
  Sapapa.Client.make(~baseUrl="http://couchdb-instance.example.com:5984");

let db =
  Sapapa.Client.db(~name=Sapapa.UrlComponent.make("my_first_database")); // <- doesn't create a db, just a nice reference

Sapapa.Database.create(db) // <- this creates the db!
|> Lwt.map(res =>
     switch (res) {
     | Ok(db) => print_endline("Database created!")
     | Error(error) =>
       print_endline(
         "Database creation failed: "
         ++ Sapapa.Database.show_create_error(error),
       )
     }
   );

Installation:#

esy add sapapa

Annotated file tree:

sapapa
├─test/      <- these are the tests
└─library/   <- this is the source code

Contribution:#

npm install -g esy
git clone git@github.com:Schniz/sapapa.git
esy install

Running Tests:#

docker-compose up -d
esy test --watch