Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

readme with examples

  • Loading branch information...
commit 20d3bdc8a0cd835f6e8e955d9da74e8f79c23e87 1 parent 6e8cb81
James Halliday authored
Showing with 148 additions and 0 deletions.
  1. +108 −0 README.markdown
  2. +40 −0 package.json
108 README.markdown
View
@@ -0,0 +1,108 @@
+autorev
+=======
+
+Blindly update couchdb documents by pulling down the latest _rev and bolting it
+to the document. This is useful for synchronizing design documents where source
+control holds the definitive copy.
+
+examples
+========
+
+command-line
+------------
+
+record.js
+
+``` js
+{
+ _id : '_design/record',
+ views : {
+ all : function (doc) {
+ if (doc.type === 'record') emit(null, doc)
+ },
+ by_experiment : function (doc) {
+ if (doc.type === 'record') emit(doc.experiment, doc)
+ },
+ by_session : function (doc) {
+ if (doc.type === 'record') emit(doc.session, doc)
+ }
+ }
+}
+```
+
+output
+
+```
+$ autorev http://localhost:5984/experiments record.js
+{"ok":true,"id":"_design/record","rev":"1-36194dcb0ade1549f4aed8c261b2c5f6"}
+$ autorev http://localhost:5984/experiments record.js
+# not updated
+```
+
+programatically
+
+``` js
+var autorev = require('autorev');
+autorev('http://localhost:5984/experiments', {
+ _id : '_design/record',
+ views : {
+ all : function (doc) {
+ if (doc.type === 'record') emit(null, doc)
+ },
+ by_experiment : function (doc) {
+ if (doc.type === 'record') emit(doc.experiment, doc)
+ },
+ by_session : function (doc) {
+ if (doc.type === 'record') emit(doc.session, doc)
+ }
+ }
+}).pipe(process.stdout);
+```
+
+methods
+=======
+
+var autorev = require('autorev')
+
+autorev(uri, doc)
+-----------------
+
+Update the document in the database at `uri` with `doc`. `doc` should have an
+`_id` field at the very least. The `_rev` field will be fetched from the latest
+revision and used to blindly update the document.
+
+Return a stream with the server response or `"# not updated\n"` if the document
+didn't change.
+
+command-line usage
+==================
+
+```
+Usage:
+
+ autorev uri
+ read docs from stdin
+
+ autorev uri [file,...]
+ read docs from filenames
+```
+
+install
+=======
+
+To get the command, with [npm](http://npmjs.org) do:
+
+```
+npm install -g autorev
+```
+
+To get the library, with [npm](http://npmjs.org) do:
+
+```
+npm install autorev
+```
+
+license
+=======
+
+MIT/X11
40 package.json
View
@@ -0,0 +1,40 @@
+{
+ "name" : "autorev",
+ "description" : "blindly update couchdb documents",
+ "version" : "0.0.0",
+ "repository" : {
+ "type" : "git",
+ "url" : "git://github.com/substack/autorev.git"
+ },
+ "main" : "index.js",
+ "bin" : {
+ "autorev" : "bin/autorev.js"
+ },
+ "keywords" : [
+ "couchdb",
+ "_rev",
+ "_id",
+ "ddoc",
+ "design",
+ "document"
+ ],
+ "directories" : {
+ "lib" : ".",
+ "example" : "example",
+ "test" : "test"
+ },
+ "dependencies" : {
+ "request" : "2.9.x",
+ "deep-equal" : "0.0.x",
+ "traverse" : "0.5.x"
+ },
+ "engines" : {
+ "node" : ">=0.4.0"
+ },
+ "license" : "MIT",
+ "author" : {
+ "name" : "James Halliday",
+ "email" : "mail@substack.net",
+ "url" : "http://substack.net"
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.