ExCouch
A pure Elixir client for CouchDB 2.
Installation
Add ex_couch
to your list of dependencies in mix.exs
:
def deps do
[
{:ex_couch, "~> 0.1.0"}
]
end
Quick start
The ExCouch
module can be supervised. Start it as part of your application.
The url
parameter is required, and should point to the base URL of your
CouchDB instance (e.g. http://localhost:5984
).
username
and password
are optional for unauthenticated servers.
defmodule MyApplication do
use Application
def start(_type, _args) do
children = [
{ExCouch, url: "http://localhost:5984", username: "couch", password: "couch"}
]
opts = [strategy: :one_for_one, name: Enseada.Supervisor]
Supervisor.start_link(children, opts)
end
end
After being started, methods can be called to interact with the server.
list = ExCouch.list_databases(limit: 10, skip: 5)
{:ok, "mydb"} = ExCouch.create_database("mydb")
if ExCouch.database_exists?("mydb") do
{:ok, info} = ExCouch.get_database("mydb")
end
Documentation
Documentation can be found at https://hexdocs.pm/ex_couch.