- Node.js is clever enough to ignore the hashbang line.
- We simply buffer the entire input in a temporary variable. Our documents are small, we don't need a clever streaming parser.
- Use console.log to write to standard out, console.warn to write to standard err. You can use process.exit(int) to exit with an error code.
- For this particular view, we had id's and rev's in the view output and therefore we could have formatted the delete command without passing the include_docs parameter. This is because I used the _all_docs view for the example. Our actual views have varying output, and relying on _all_docs makes the script work with all of them. (Please don't feed your _all_docs view through this script, just delete the database!)