diff options
author | Jordan Bracco <href@random.sh> | 2022-12-11 05:54:28 +0000 |
---|---|---|
committer | Jordan Bracco <href@random.sh> | 2022-12-11 05:56:34 +0000 |
commit | 65777ebe52af3fd14e8c121da4868832f3d83c62 (patch) | |
tree | 85d7a75061259e994f5d4aba7b9cfab12ccb4f56 /lib/couch.ex | |
parent | feat(gpt): continue prompt, some fixes (diff) |
feat(couch): `Couch.get(db, :all_docs)` shorthand for `"_all_docs"`
Diffstat (limited to 'lib/couch.ex')
-rw-r--r-- | lib/couch.ex | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/couch.ex b/lib/couch.ex index 50b031c..71f86a3 100644 --- a/lib/couch.ex +++ b/lib/couch.ex @@ -24,8 +24,10 @@ defmodule Couch do `params` are [documented here](https://docs.couchdb.org/en/3.2.2-docs/api/document/common.html) """ - @spec get(String.t(), String.t(), Keyword.t()) :: {:ok, Map.t()} | {:error, :not_found} | {:error, any()} - def get(db, doc, params \\ []) do + @spec get(String.t(), String.t() | :all_docs, Keyword.t()) :: {:ok, Map.t()} | {:error, :not_found} | {:error, any()} + def get(db, doc, params \\ []) + def get(db, :all_docs, params), do: get(db, "_all_docs", params) + def get(db, doc, params) do {url, headers, options} = prepare_request([db, doc], [], params) case HTTPoison.get(url, headers, options) do {:ok, %HTTPoison.Response{status_code: 200, body: body}} -> |