Created
January 20, 2014 15:01
-
-
Save revington/8521351 to your computer and use it in GitHub Desktop.
Delete all my test db from couch db
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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