-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Labels
Description
With kivik/v4 and couchdb/v4
github.com/go-kivik/couchdb/v4 v4.0.0-20201202133216-34bafb9698c8
github.com/go-kivik/kivik/v4 v4.0.0-20201202093909-da42f0daa1b2
It seems the _replicator database has to be created explicitly (fauxton does this as well). Without it, GetReplications() will fail
package main
import (
"context"
"fmt"
_ "github.com/go-kivik/couchdb/v4"
"github.com/go-kivik/kivik/v4"
)
func main() {
client, err := kivik.New("couch", "http://admin:a-secret@localhost:5984")
if err != nil {
panic(err)
}
existing, err := client.GetReplications(context.TODO())
if err != nil {
fmt.Printf("Failed to get replications: %v\n", err)
if err := client.CreateDB(context.TODO(), "_replicator"); err != nil {
panic(err)
}
existing, err = client.GetReplications(context.TODO())
if err != nil {
fmt.Println("Still doesn't work, giving up")
}
}
fmt.Printf("Found %d replications\n", len(existing))
}
will print
# make sure it does not hold previous state, `docker rm` previous instances
» docker run -d -p 5984:5984 -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=a-secret --name my-couchdb couchdb:3
» go run cmd/repl/main.go
Failed to get replications: Not Found: Database does not exist.
Found 0 replications
I'm not sure if this is something Kivik should deal with, but at least it might be worth mentioning