curl
HOST="http://127.0.0.1:5984"1. Create database:
curl -u admin:admin -X PUT $HOST/db {"ok":true}
2. Delete database
curl -u admin:admin -X DELETE $HOST/db {"ok":true}
3. Create document
curl -X PUT $HOST/db/foo -d '{"count":1}' {"ok":true,"id":"foo","rev":"1-74620ecf527d29daaab9c2b465fbce66"}
4. Update document
curl -X PUT $HOST/db-replica/foo -d '{"count":2, "_rev":"1-74620ecf527d29daaab9c2b465fbce66"}' {"ok":true,"id":"foo","rev":"2-de0ea16f8621cbac506d23a0fbbde08a"}
5. Replication
curl -u admin:admin -H "Content-Type:application/json" -X POST $HOST/_replicate -d '{"source":"db", "target":"http://127.0.0.1:5984/db-replica"}' {"ok":true,"session_id":"48d43591b4f145ae08a9207dcc586fe2","source_last_seq":1,"replication_id_version":3,"history":[{"session_id":"48d43591b4f145ae08a9207dcc586fe2","start_time":"Wed, 15 Jan 2014 09:59:42 GMT","end_time":"Wed, 15 Jan 2014 09:59:42 GMT","start_last_seq":0,"end_last_seq":1,"recorded_seq":1,"missing_checked":1,"missing_found":1,"docs_read":1,"docs_written":1,"doc_write_failures":0}]}
6. Changes
curl $HOST/_changes?feed=longpoll&heartbeat=300000&style=all_docs&since=233
Views
1. View conflictsfunction(doc) { if(doc._conflicts) { emit(doc._conflicts, null); } }
No comments:
Post a Comment