elidiazgt
12/5/2016 - 6:38 PM

cheatsheet - coachdb database

COACHDB


# List all DB's
curl -X GET http://127.0.0.1:5984/_all_dbs

# Create DB
curl -X PUT http://127.0.0.1:5984/contacts

#Delete DB
curl -X DELETE http://127.0.0.1:5984/contacts


#Insert document (record)
curl -X put http://127.0.0.1:5984/contacts/eli -d
'{"firstName":"eli","lastName":"diaz"}'

#Get documents
curl -X GET http://127.0.0.1:5984/contacts/eli

#Delete document
curl -X DELETE http://127.0.0.1:5984/contacts/eli?rev={FROM THE GET}


# Copy record (document)
curl -X COPY http://127.0.0.1:5984/contacts/eli -H "Destination: tylerdurden"

# Update record (document): You'll need the rev number which the GET record command can supply.
curl -X PUT http://127.0.0.1:5984/contacts/eli -d
'{"_rev":"{REV FROM GET}","firstName":"Tyler","lastName":"Durden"}


#List all documents
curl -X GET http://127.0.0.1:5984/contacts/_all_docs

#List all documents (ORDER and set LIMIT)
curl -X GET http://127.0.0.1:5984/contacts/_all_docs?descending=true\\&limit=1

#All documents in the DB (as well as deleted ones) ordered by last modified.
#Look for the following next to deleted records: "deleted":true
curl -X GET http://127.0.0.1:5984/contacts/_all_docs_by_seq