Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/schniz/sapapa
A soothing CouchDB client for Reason and OCaml
https://github.com/schniz/sapapa
couchdb couchdb-client ocaml reasonml
Last synced: 12 days ago
JSON representation
A soothing CouchDB client for Reason and OCaml
- Host: GitHub
- URL: https://github.com/schniz/sapapa
- Owner: Schniz
- Created: 2019-05-20T07:31:13.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-10-23T14:36:49.000Z (about 5 years ago)
- Last Synced: 2024-11-30T02:12:38.375Z (23 days ago)
- Topics: couchdb, couchdb-client, ocaml, reasonml
- Language: OCaml
- Homepage:
- Size: 153 KB
- Stars: 17
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sapapa π
[![Build Status](https://dev.azure.com/galstar0385/sapapa/_apis/build/status/Schniz.sapapa?branchName=master)](https://dev.azure.com/galstar0385/sapapa/_build/latest?definitionId=5&branchName=master)
> A soothing CouchDB client for native Reason and OCaml. Just Relax. π
Under the hood, it calmly leverages [Yojson](https://github.com/ocaml-community/yojson) for JSON parsing and [Lwt](https://github.com/ocsigen/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:
```reason
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 referenceSapapa.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:
```bash
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 [email protected]:Schniz/sapapa.git
esy install
```## Running Tests:
```
docker-compose up -d
esy test --watch
```