-fork of TechMagister/couchdb.cr
- fixed "sort"
- updated for crystal 0.35.1 (will update for v1 shortly...circleCI = never. tests updated = shortly)
CouchDB client written in crystal
Add this to your application's shard.yml
:
dependencies:
couchdb:
github: vectorselector/couchdb.cr
require "couchdb"
client = CouchDB::Client.new "http://127.0.0.1:5984"
info = client.server_info
info.couchdb # Welcome
info.version # 2.1.1
info.vendor.name # The Apache Software Foundation
usage overview/example:
COUCHDB_URL = ENV["COUCHDB_URL"]? || "http://127.0.0.1:5984"
DB = CouchDB::Client.new COUCHDB_URL
myQuery = CouchDB::FindQuery.from_json %({"selector":{"user_id":"#{userId}", "$not":{"archived":true} }, "sort":[{"timestamp":"desc"}], "limit":#{limit} })
myThing = DB.find_document("things", myQuery).docs.not_nil!.first
"sort" takes an array of EITHER a String or an object as such [{"fieldname1": "desc"}, {"fieldname2": "asc"}] per CouchDB docs https://docs.couchdb.org/en/2.3.1/api/database/find.html#sort-syntax
"skip" is like "limit" and goes outside the "selector"...
- Get server info
- Create Database
- Delete Database
- List Databases
- Get new uuid
- Create Documents
- Find all the documents
- Find Documents with criteria
- Delete Documents
- Update Documents
- Fork it ( https://github.com/vectorselector/couchdb/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- TechMagister Arnaud Fernandés - creator, maintainer
- Schniz Gal Schlezinger - contributor
- drhuffman12 Daniel Huffman - contributor