Sofa.DB (sofa v0.1.3)
View SourceDocumentation for Sofa.DB
, a test-driven idiomatic Apache CouchDB client.
If the only tool you have is CouchDB, then everything looks like
{:ok, :relax}
Examples
iex> sofa = Sofa.init("http://admin:passwd@localhost:5984/")
|> Sofa.client()
|> Sofa.connect!()
#Sofa<"...">
iex> Sofa.DB.create(sofa, "testy")
{:ok,
#Sofa<
client: %Tesla.Client{},
database: "testy7",
uri: %URI{},
...
>,
%Sofa.Response{
body: %{"ok" => true},
headers: %{
cache_control: "must-revalidate",
content_length: 95,
content_type: "application/json",
couch_body_time: 0,
couch_request_id: "aa6cc50741",
date: "Sun, 25 Apr 2021 20:04:34 GMT",
server: "CouchDB/3.1.1 (Erlang OTP/22)"
},
method: :put,
query: [],
status: 201,
url: "http://localhost:5984/testy7"
}}
iex> Sofa.DB.open!(sofa, "testy")
#Sofa<
database: "testy",
client: %Tesla.Client{},
...>
Summary
Functions
create DB. Only available to cluster admin users.
Delete DB. Only available to cluster admin users.
Get DB info. Only available to database & cluster admin users.
Open DB. Checks if supplied credentials have access to the DB, and returns
updated %Sofa{}
struct with DB. Ideal for subsequent use to read/write Docs.
Bang! version of open/2. Opens DB and raises on failure. Ideal for piping directly into reading and writing Docs.
Functions
create DB. Only available to cluster admin users.
Delete DB. Only available to cluster admin users.
Get DB info. Only available to database & cluster admin users.
Open DB. Checks if supplied credentials have access to the DB, and returns
updated %Sofa{}
struct with DB. Ideal for subsequent use to read/write Docs.
Bang! version of open/2. Opens DB and raises on failure. Ideal for piping directly into reading and writing Docs.