Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@robertkowalski
Created May 24, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertkowalski/cf66febc51ccf25e1c43 to your computer and use it in GitHub Desktop.
Save robertkowalski/cf66febc51ccf25e1c43 to your computer and use it in GitHub Desktop.

Code

AnimalDB

Get it from:

http://examples.cloudant.com/animaldb

Code for local CouchDB (2.x)

curl -XPOST http://localhost:5984/animaldb/_index \
-H 'Content-type: application/json' \
-d '{"index": {"fields": ["min_weight"]}}'
curl -XPOST http://localhost:5984/animaldb/_find \
 -H 'Content-type: application/json' \
-d '{"selector": {"min_weight": {"$gt": 10}}}'
curl -XPOST http://localhost:5984/animaldb/_find \
 -H 'Content-type: application/json' \
-d '{"selector": {"min_weight": {"$eq": 40}}}'

Code for Cloudant

Replace $YOURUSERNAME with your username

curl -XPOST http://$YOURUSERNAME.cloudant.com/animaldb/_index \
-H 'Content-type: application/json' \
-d '{"index": {"fields": ["min_weight"]}}'
curl -XPOST http://$YOURUSERNAME.cloudant.com/animaldb/_find \
 -H 'Content-type: application/json' \
-d '{"selector": {"min_weight": {"$gt": 10}}}'
curl -XPOST http://$YOURUSERNAME.cloudant.com/animaldb/_find \
 -H 'Content-type: application/json' \
-d '{"selector": {"min_weight": {"$eq": 40}}}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment