raven-shell
Advanced tools
+2
-2
| { | ||
| "name": "raven-shell", | ||
| "preferGlobal": "true", | ||
| "version": "0.0.7", | ||
| "version": "0.0.8", | ||
| "author": "Tony Heupel <tonyheupel@gmail.com>", | ||
@@ -27,3 +27,3 @@ "description": "A command-line interface to RavenDB", | ||
| "dependencies" : { | ||
| "ravendb": ">=0.0.6", | ||
| "ravendb": ">=0.0.8", | ||
| "argparse": ">=0.1.1" | ||
@@ -30,0 +30,0 @@ }, |
+40
-7
@@ -7,3 +7,3 @@ #!/usr/bin/env node | ||
| var version = '0.0.7' // Keep in sync with package.json | ||
| var version = '0.0.8' // Keep in sync with package.json | ||
@@ -173,3 +173,3 @@ var createDatastore = function(r, url, databaseName) { | ||
| r.defineCommand('find', { | ||
| help: 'Find documents (e.g., .find { firstName: "Tony" })', | ||
| help: 'Find documents ".find <JSON object> [start [count]]" (e.g., .find { firstName: "Tony" } 20 100)', | ||
| action: function(args) { | ||
@@ -179,5 +179,19 @@ try { | ||
| eval('var argsDoc = ' + args) | ||
| // Parse args: { attr: value } [start [count]] | ||
| // .find { some: 'thing'} 20 100 | ||
| // ^-------1------^^--2--^ | ||
| // 3 5 | ||
| // ^4-^ | ||
| // match[0] = "{ some: 'thing'} 20 100" | ||
| // match[1] = "{ some: 'thing'}" | ||
| // match[2] = " 20 100" | ||
| // match[3] = "20" | ||
| // match[4] = " 100" | ||
| // match[5] = "100" | ||
| var match = /(\{.*\})(\s+(\d+)(\s+(\d+))?)?/.exec(args) | ||
| eval('var doc = ' + match[1]) | ||
| var start = match[3] ? parseInt(match[3]) : null | ||
| var count = match[5] ? parseInt(match[5]) : null | ||
| r.context.db.find(argsDoc, function(error, result) { | ||
| r.context.db.find(doc, start, count, function(error, result) { | ||
| if (error) console.error(error) | ||
@@ -201,7 +215,26 @@ | ||
| try { | ||
| var match = /(\w+)/.exec(args) | ||
| // Parse args: [collection [start [count]]] | ||
| // .count Users 50 100 | ||
| // ^-1-^^--2--^ | ||
| // 3 5 | ||
| // ^4-^ | ||
| // match[0] = "Users 50 100" | ||
| // match[1] = "Users" | ||
| // match[2] = " 50 100" | ||
| // match[3] = "50" | ||
| // match[4] = " 100" | ||
| // match[5] = "100" | ||
| var match = /(\w+)(\s+(\d+)(\s+(\d+))?)?/.exec(args) | ||
| var collection = (match && match.length == 2) ? match[1] : null | ||
| var collection = start = count = null | ||
| if (match) { | ||
| collection = match[1] | ||
| start = match[3] ? parseInt(match[3]) : null | ||
| count = match[5] ? parseInt(match[5]) : null | ||
| } | ||
| r.context.db.getDocsInCollection(collection, function(error, result) { | ||
| r.context.db.getDocsInCollection(collection, start, count, function(error, result) { | ||
| if (error) console.error(error) | ||
@@ -208,0 +241,0 @@ |
Sorry, the diff of this file is not supported yet
16813
12.32%390
8.33%Updated