couch2mongo / couchapi

Provide an CouchDB API for reading and writing with MongoDB to make migration easier.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CouchAPI

A shift from Apache CouchDB to MongoDB addresses the need for superior scalability, flexibility, and efficiency. With the innovative use of a proxy layer developed in Rust, a modern systems programming language, this migration can be significantly simplified, making the transition seamless and efficient.

Green Man Gaming uses this in production, serving many transactions per second and without it, our store would end up offline. We're making this public so others can get as much use from it as we have!

Requirements

You need Rust Stable and Nightly (we only use Nightly for rustfmt)!

rustup update stable
rustup toolchain install nightly

Building

cargo build

Running

cargo run -- --help

See config.toml for an example configuration file.

Pro-tips for development

If you get a random error about traits add #[debug_handler] to the relevant handler, and you'll get actual information. Please don't commit code with this handler!

Usage

Whenever you see a dbname, it means a collection.

Get a document

curl -X GET http://localhost:5984/dbname/docid

Create a document

curl -X POST http://localhost:5984/dbname -d '{"_id": "docid", "foo": "bar"}'

OR

curl -X PUT http://localhost:5984/dbname/docid -d '{"foo": "bar"}'

Update a document

curl -X PUT http://localhost:5984/dbname/docid -d '{"_id": "docid", "_rev": "1-1234", "foo": "baz"}'

OR

curl -X PUT http://localhost:5984/dbname/docid -d '{"foo": "baz"}' -H 'If-Match: 1-1234'

OR

curl -X POST http://localhost:5984/dbname -d '{"_id": "docid", "_rev": "1-1234", "foo": "baz"}'

Delete a document

curl -X DELETE http://localhost:5984/dbname/docid?rev=1-1234

About

Provide an CouchDB API for reading and writing with MongoDB to make migration easier.

License:Apache License 2.0


Languages

Language:Rust 99.4%Language:JavaScript 0.3%Language:Dockerfile 0.3%