Skip to content

Instantly share code, notes, and snippets.

@glynnbird
Created October 23, 2014 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save glynnbird/7e36d1c92d5136dec714 to your computer and use it in GitHub Desktop.
Save glynnbird/7e36d1c92d5136dec714 to your computer and use it in GitHub Desktop.
#!/bin/bash
DEST="mydb"
DOC="mydoc"
# create destination database
ccurl -X PUT "/$DEST"
# loop 1-->10
for i in `seq 1 10`; do
DB="db$i"
TS=`date +%s`
json="{ \"_id\": \"$DOC\", \"ts\": $TS}"
echo "Creating database $DB with single doc $json"
# create a database e.g. DB1
ccurl -X PUT "/$DB"
# put a document in it e.g. { "_id": "mydoc", "ts": 42 }
ccurl -X POST -d "$json" "/$DB"
# replicate this database to mydb
repl="{ \"source\": \"$DB\", \"target\": \"mydb\" }"
echo "Replicating to $DEST"
ccurl -X POST -d "$repl" "/_replicator"
sleep 1
done
# let replication complete
sleep 10
# read back our conflicted document /mydb/mydoc
ccurl "/$DEST/$DOC?conflicts=true"
@snopoke
Copy link

snopoke commented Apr 9, 2015

updated version that actually works without the need for lots of tweaks: https://gist.github.com/snopoke/cc62366f9856e3f301f3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment