Code Monkey home page Code Monkey logo

couchdb-ex's Introduction

CouchDBEx

Build Status Coverage Status Hex.pm

This is supposed to be a good couchdb interface for elixir, documented, tested and other things, that's in progress for now, i know there are erlang and elixir clients already, but they are basically dead and not documented very good if at all, although you might also want to look at icouch

Some features implemented:

  • Single and mass document insertion/deletion/update
  • Subscribing to changes in the database
  • Basic and cookie authentification
  • Database configuration retreival and setting
  • Document finding
  • Attachment uploading/retreival/deletion
  • Index creation/deletion/listing
  • Replication

Documentation can be found here

Usage example

1. Add the dependency in your application's mix.exs

defp deps do
    [
        # ...
        {:couchdb_ex, "~> 0.2.1"},
    ]
end

2. Use it in your application

2.1. Elixir application

First, add the couchdb worker to your supervisor

    children = [
      {CouchDBEx.Worker, [
          hostname: "http://localhost",
          username: "couchdb",
          password: "couchdb",
          auth_method: :cookie # or :basic, if you feel like it
        ]}
    ]

    opts = [strategy: :one_for_one, name: Application.Supervisor]
    Supervisor.start_link(children, opts)

2.2. Phoenix framework application

Find the application.ex which is usually present in hello/lib/hello/ where hello is your project name. Phoenix uses soft-deprecated Supervisor.Spec thus the minor difference in usage.

Then add the couchdb worker to your application module

def start(_type, _args) do
    import Supervisor.Spec

    children = [
        supervisor(HelloWeb.Endpoint, []),
        worker(CouchDBEx.Worker, [[
            hostname: "http://localhost",
            username: "couchdb",
            password: "couchdb",
            auth_method: :cookie # or :basic, if you feel like it
        ]])
    ]
    opts = [strategy: :one_for_one, name: Hello.Supervisor]
    Supervisor.start_link(children, opts)
end

3. You are all set to make DB operations

Now, you can use functions from CouchDBEx

:ok = CouchDBEx.db_create("couchdb-ex-test")

{:ok, doc} = CouchDBEx.document_insert_one(%{test_value: 1}, "couchdb-ex-test")

This library also includes subscribing to database changes with CouchDBEx.changes_sub and _unsub, see respective functions documentation for more

Contribution

Please do open issues and pull requests if you feel like something is wrong, this library probably doesn't have everything you need yet.

couchdb-ex's People

Contributors

chintan-mishra avatar vaartis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

couchdb-ex's Issues

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.