Code Monkey home page Code Monkey logo

icouch's People

Contributors

p2k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

icouch's Issues

Is Mango Query implemented?

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.

How would you suggest we find a particular document with matching key-value pair?

Using Views with ICouch

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.

ChangesFollower.init/1 doesn't comply with GenServer spec

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.

Issue using save_doc/3 with Map (or ICouch.Document)

** (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

Steps to Reproduce

# 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.