Skip to content

Instantly share code, notes, and snippets.

@revington
Created January 20, 2014 15:01
Show Gist options
  • Save revington/8521351 to your computer and use it in GitHub Desktop.
Save revington/8521351 to your computer and use it in GitHub Desktop.
Delete all my test db from couch db
#!/bin/bash
while read -r line; do
curl -X DELETE http://localhost:5984/$line
done < <( curl http://localhost:5984/_all_dbs 2> /dev/null | node -e "
process.stdin.setEncoding('utf8');
process.stdin.resume();
var buf = '';
process.stdin.on('data', function(chunk){
buf += chunk;
});
process.stdin.on('end', function(){
var obj = JSON.parse(buf);
obj.filter(function(x){
return 0 === x.indexOf('testdb');
}).forEach(function(x){
// write to stdout only testdb*
process.stdout.write(x + '\n');
});
});
")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment