GithubHelp home page GithubHelp logo

go-couchdb's Introduction

What's this?

go-couchdb is yet another CouchDB client written in Go. It was written because all the other ones didn't provide functionality that I need.

The API is not fully baked at this time and may change.

This project contains three Go packages:

package couchdb GoDoc

import "github.com/fjl/go-couchdb"

This wraps the CouchDB HTTP API.

package couchapp GoDoc

import "github.com/fjl/go-couchdb/couchapp"

This provides functionality similar to the original couchapp tool, namely compiling a filesystem directory into a JSON object and storing the object as a CouchDB design document.

package couchdaemon GoDoc

import "github.com/fjl/go-couchdb/couchdaemon"

This package contains some functions that help you write Go programs that run as a daemon started by CouchDB, e.g. fetching values from the CouchDB config.

Tests

You can run the unit tests with go test.

Build Status

go-couchdb's People

Contributors

fjl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar

go-couchdb's Issues

Design documents improperly escaped

While trying to query a view, I discovered that design documents are improperly escaped.

The first indication of a problem was that go-couchdb was complaining of insufficient permissions to access the view:

GET http://xxx.xxx.xxx/_users/_design/users/_view/by_provider: (403) forbidden: Only admins can access design document actions for system databases.

And my couch log showed these requests:

[Tue, 01 Sep 2015 22:54:29 GMT] [info] [<0.268.0>] xxx.xxx.xxx.xxx - - GET /_users/_design%2Fusers/_view/by_provider 301
[Tue, 01 Sep 2015 22:54:30 GMT] [info] [<0.269.0>] xxx.xxx.xxx.xxx - - GET /_users/_design/users/_view/by_provider 403

So it turns out the redirect wasn't getting the necessary auth headers. But the real problem here is that the slash in _design/users shouldn't be escaped at all.

I have a PR coming soon.

client question

Can I use a client concurrently or should I create a new client each time?

Future of this library

Hi Felix. I'm curious how you envisage the future of this library. There are a couple of golang Couch DB clients on Github but this one has the most stars and probably the best code too.

Unfortunately there are some good open pull requests against this library that are not taken care off. Also it seems like there wasn't any other activity in this repo for about 2 years.

I have forked this repo and have incorporated most of the pull requests. I'm happy to continue to maintain the code but would need to know what your take on it is as we would need to figure out how we want to handle it going forward.

Cheers
Tim

What is the license for this package?

I don't see any licensing terms posted. Which, strictly speaking, means this can't be used as part of any open-source projects, because it's not labeled as open source, so by default--at least in most jurisdictions, by my understanding, all rights are retained by the author.

Would you mind clarifying the license terms for this library?

_find

Just wondering how you would hit the _find CouchDB endpoint. I can't see a POST method in couchDB.DB. Is there another way?

JSON decoding failure

I haven't had time to look into the cause of this, but the following fails silently:

package main

import (
        "fmt"
        "log"
        couch "vsys/go-couchdb"
)

func main() {
        server, err := couch.NewClient("http://127.0.0.1:5984/", nil)
        if err != nil {
                log.Fatalf("Error creating client: %v", err)
        }
        db := server.DB("my_db")
        allDocs := struct {
                Offset int `json:"offset"`
                Rows   []struct {
                        Id    string `json:"id"`
                        Key   string `json:"key"`
                        Value struct {
                                Rev string `json:"rev"`
                        } `json:"rows"`
                }
                TotalRows int `json:"total_rows"`
        }{}

        err = db.AllDocs(&allDocs, nil)
        if err != nil {
                log.Fatalf("Failed to get document list: %v", err)
        }
        fmt.Printf("Got document list with %d rows\n", len(allDocs.Rows))
}

The tag json:"rows"\ is on the wrong line; Value should be tagged as the JSON name value and Rows should be tagged as rows. Despite this, everything except the Rev field is decoded correctly.

Slashes in IDs not encoded

I'm doing Db.Get("user/foo"), but the slash isn't encoded, resulting in requesting /db/user/foo from CouchDB (the slash should be encoded to %2F).

Sequence IDs are no longer integers

As of CouchDB 2.0, Sequence IDs are no longer integers, and can be any valid JSON object. As far as I know, the only place this is exposed in this library is in the ChangesFeed. I suggest changing the SeqID to a json.RawMessage type to accommodate this change.

Another option might be to expose the raw Seq value as a separate field (and set Seq to 0 when it's not an integer). This would allow CouchDB 1.6 users to continue using this library with no changes.

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.