Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/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

This comment has been minimized.

Show comment Hide comment
@snopoke

snopoke Apr 9, 2015

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

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