meetnow / icouch Goto Github PK
View Code? Open in Web Editor NEWCouchDB client for Elixir using ibrowse
License: Other
CouchDB client for Elixir using ibrowse
License: Other
It should be possible to drop an instance of ChangesFollower directly into a Supervision tree, so it can act as a normally managed Worker, but it returns a different set of tuples than expected, so this fails.
As ChangesFollower registers as a behaviour, it must comply with the GenServer spec:
@callback init(args :: term()) ::
{:ok, state}
| {:ok, state, timeout() | :hibernate | {:continue, term()}}
| :ignore
| {:stop, reason :: any()}
when state: any()
However its return spec is different, returning:
@callback init(args :: term) ::
{:ok, db :: ICouch.DB.t, state} |
{:ok, db :: ICouch.DB.t, opts :: [option], state} |
{:ok, db :: ICouch.DB.t, opts :: [option], state, timeout | :hibernate} |
:ignore |
{:stop, reason :: any} when state: term
There's presumably a reason for doing it this way, but the result is that an additional GenServer-compliant behaviour needs to be wrapped around this before it can be used correctly in a standard OTP supervision tree.
Would you take a breaking change PR for ChangesFollower that deals with the extraneous items db
, opts
simply by removing them entirely from the returned tuple? It seems that any process spawning a ChangesFollower will already have the DB and options it passes into the worker.
I'm still working on a wrapper but how do you handle this at meetnow? It seems better to achieve this directly in ICouch.
I am playing with this library, Elixir, and CouchDB and couldn't find any reference to Mango Queries in the docs or the library code.
** (FunctionClauseError) no function clause matching in ICouch.DB.server_endpoint/2
The following arguments were given to ICouch.DB.server_endpoint/2:
# 1
%ICouch.DB{name: "my-test-db",
server: %ICouch.Server{direct: nil,
ib_options: [basic_auth: {'username', 'password'}], timeout: nil,
uri: %URI{authority: "127.0.0.1:5984", fragment: nil, host: "127.0.0.1",
path: "/", port: 5984, query: nil, scheme: "http", userinfo: nil}}}
# 2
{nil, []}
Attempted function clauses (showing 3 out of 3):
def server_endpoint(%ICouch.DB{name: db_name}, {path, options}) when is_binary(path)
def server_endpoint(%ICouch.DB{name: db_name}, %URI{path: path} = endpoint)
def server_endpoint(%ICouch.DB{name: db_name}, endpoint) when is_binary(endpoint)
(icouch) lib/icouch/db.ex:65: ICouch.DB.server_endpoint/2
(icouch) lib/icouch/db.ex:33: ICouch.DB.send_req/4
(icouch) lib/icouch.ex:526: ICouch.save_doc/3
# Create server connection
server = ICouch.server_connection("http://127.0.0.1:5984/", basic_auth: {"username", "password"})
# Open database
{:ok, db} = ICouch.open_db(server, "my-test-db")
# Try to insert a document
doc = ICouch.save_doc(db, %{name: "Someone", email: "[email protected]"})
# Boom!
# Second approach
doc = ICouch.Document.new(%{name: "Someone", email: "[email protected]"})
new_doc = ICouch.save_doc(db, doc)
# Same Boom!
I'd appreciate any advise if I'm reading the docs incorrectly.
ICouch.open_view(db, "_design_docs")
returns the desired result. However, while using ICouch.open_view db, "_design/myDesignDoc
we get the {:error, :not_found}
. This is resolved if we change the query to ICouch.open_view db, "myDesignDoc/_design
Is this the desired behavior? (I am hoping not)
Great, if not then the issue is in the third case statement in the function defined starting from the line https://github.com/meetnow/icouch/blob/master/lib/icouch.ex#L736
I will be happy to do a PR if you are accepting any.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.