ExCouch v0.1.0-alpha ExCouch View Source
A pure Elixir client for CouchDB.
Implements API calls to CouchDB 2.
Starting the client
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.
Example
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
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Create a new database
Checks if a database with the given name already exists
Delete a database
Retrieve information about a database
Callback invoked to start the supervisor and during hot code upgrades.
List all available databases
Link to this section Types
error()
View Sourceerror() :: {:error, atom(), String.t()} | {:error, :unexpected, Tesla.Env.t()} | {:error, :client, any()}
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Create a new database
Checks if a database with the given name already exists
Delete a database
Retrieve information about a database
Callback invoked to start the supervisor and during hot code upgrades.
Developers typically invoke Supervisor.init/2
at the end of their
init callback to return the proper supervision flags.
Callback implementation for Supervisor.init/1
.
list_databases(opts \\ [])
View Sourcelist_databases( opts :: [ descending: boolean(), start_key: any(), end_key: any(), limit: pos_integer(), skip: pos_integer() ] ) :: [String.t()] | error()
List all available databases