diff options
author | adam <anton@adamansky.com> | 2012-12-20 17:59:00 +0700 |
---|---|---|
committer | adam <anton@adamansky.com> | 2012-12-20 17:59:00 +0700 |
commit | ce6e8cbf76e2c8817f8ddc42e13a279fc5b18584 (patch) | |
tree | aa6b091a205fddd60702c4c5a40e256e671dbda5 /node | |
parent | 99e1a2321961923cab53f78adaa3512795132490 (diff) | |
download | ejdb-ce6e8cbf76e2c8817f8ddc42e13a279fc5b18584.tar.gz ejdb-ce6e8cbf76e2c8817f8ddc42e13a279fc5b18584.tar.bz2 ejdb-ce6e8cbf76e2c8817f8ddc42e13a279fc5b18584.zip |
#6 almost done
Diffstat (limited to 'node')
-rw-r--r-- | node/bin/cli.js | 159 | ||||
-rw-r--r-- | node/clinspect.js | 370 | ||||
-rw-r--r-- | node/ejdb.js | 19 | ||||
-rw-r--r-- | node/ejdb_native.cc | 22 |
4 files changed, 519 insertions, 51 deletions
diff --git a/node/bin/cli.js b/node/bin/cli.js index ab00957..41034b5 100644 --- a/node/bin/cli.js +++ b/node/bin/cli.js @@ -1,20 +1,111 @@ -//EJDB console +#!/usr/bin/env node +var cdb = null; //current DB desc +const maxInspectRows = 10; +const maxInspectDepth = 10; +var useColors = true; +var quiet = false; + +//Parse aguments +(function() { + var args = process.argv; + for (var i = 2; i < args.length; ++i) { + var a = args[i]; + if (["--no-colors", "-nc"].indexOf(a) != -1) { + useColors = false; + } else if (["--quiet", "-q"].indexOf(a) != -1) { + quiet = true; + } + } +})(); -var path = require("path"); -var EJDB = require("ejdb"); +if (!quiet) { + var pkg = require("../../package.json"); + console.log("Welcome to EJDB CLI v" + pkg.version); +} -var cdb = null; //current DB desc +var util = require("util"); +var path = require("path"); +var EJDB = require("../ejdb.js"); +var clinspect = require("../clinspect.js"); + + +//Init help hints +Object.defineProperty(EJDB.open, "_help_", + {value : "(dbFile, [openMode]) Open database"}); +Object.defineProperty(EJDB.prototype.close, "_help_", + {value : "Close database"}); +Object.defineProperty(EJDB.prototype.isOpen, "_help_", + {value : "Check if database in opened state"}); +Object.defineProperty(EJDB.prototype.ensureCollection, "_help_", + {value : "(cname, [copts]) Creates new collection if it does't exists"}); +Object.defineProperty(EJDB.prototype.removeCollection, "_help_", + {value : "(cname, [prune], [cb]) Removes collection, " + + "if `prune` is true collection db will be erased from disk."}); +Object.defineProperty(EJDB.prototype.save, "_help_", + {value : "(cname, object|array of object, [opts], [cb]) " + + "Save/update specified JSON objects in the collection."}); +Object.defineProperty(EJDB.prototype.load, "_help_", + {value : "(cname, oid, [cb]) Loads object identified by OID from the collection"}); +Object.defineProperty(EJDB.prototype.remove, "_help_", + {value : "(cname, oid, [cb]) Removes object from the collection"}); +Object.defineProperty(EJDB.prototype.find, "_help_", + {value : "(cname, [qobj], [qobjarr], [hints], [cb]) Execute query on collection"}); +Object.defineProperty(EJDB.prototype.findOne, "_help_", + {value : "(cname, [qobj], [qobjarr], [hints], [cb]) Retrive one object from the collection"}); +Object.defineProperty(EJDB.prototype.update, "_help_", + {value : "(cname, [qobj], [qobjarr], [hints], [cb]) Perform update query on collection"}); +Object.defineProperty(EJDB.prototype.count, "_help_", + {value : "(cname, [qobj], [qobjarr], [hints], [cb]) Convenient count(*) operation"}); +Object.defineProperty(EJDB.prototype.sync, "_help_", + {value : "Synchronize entire EJDB database with disk"}); +Object.defineProperty(EJDB.prototype.dropIndexes, "_help_", + {value : "(cname, path, [cb]) Drop indexes of all types for JSON field path"}); +Object.defineProperty(EJDB.prototype.optimizeIndexes, "_help_", + {value : "(cname, path, [cb]) Optimize indexes of all types for JSON field path"}); + +Object.defineProperty(EJDB.prototype.ensureStringIndex, "_help_", + {value : "(cname, path, [cb]) Ensure String index for JSON field path"}); +Object.defineProperty(EJDB.prototype.rebuildStringIndex, "_help_", + {value : "(cname, path, [cb])"}); +Object.defineProperty(EJDB.prototype.dropStringIndex, "_help_", + {value : "(cname, path, [cb])"}); + +Object.defineProperty(EJDB.prototype.ensureIStringIndex, "_help_", + {value : "(cname, path, [cb]) Ensure case insensitive String index for JSON field path"}); +Object.defineProperty(EJDB.prototype.rebuildIStringIndex, "_help_", + {value : "(cname, path, [cb])"}); +Object.defineProperty(EJDB.prototype.dropIStringIndex, "_help_", + {value : "(cname, path, [cb])"}); + +Object.defineProperty(EJDB.prototype.ensureNumberIndex, "_help_", + {value : "(cname, path, [cb]) Ensure index presence of Number type for JSON field path"}); +Object.defineProperty(EJDB.prototype.rebuildNumberIndex, "_help_", + {value : "(cname, path, [cb])"}); +Object.defineProperty(EJDB.prototype.dropNumberIndex, "_help_", + {value : "(cname, path, [cb])"}); + +Object.defineProperty(EJDB.prototype.ensureArrayIndex, "_help_", + {value : "(cname, path, [cb]) Ensure index presence of Array type for JSON field path"}); +Object.defineProperty(EJDB.prototype.rebuildArrayIndex, "_help_", + {value : "(cname, path, [cb])"}); +Object.defineProperty(EJDB.prototype.dropArrayIndex, "_help_", + {value : "(cname, path, [cb])"}); + +Object.defineProperty(EJDB.prototype.getDBMeta, "_help_", + {value : "Get description of EJDB database and its collections"}); repl = require("repl").start({ - prompt : "ejc> ", + prompt : "ejdb> ", input : process.stdin, output : process.stdout, terminal : true, - useColors : true + writer : function(obj) { + return clinspect.inspect(obj, maxInspectDepth, useColors) + } }); -//console.log("repl.context=" + repl.context); +//console.log("MF=" + module.filename); var dbctl = { open : function(dbpath) { @@ -34,7 +125,7 @@ var dbctl = { }, status : function() { - return dbstatus(cdb); + return dbstatus(cdb); }, close : function() { @@ -49,6 +140,9 @@ var dbctl = { syncdbctx(); } }; +Object.defineProperty(dbctl.open, "_help_", {value : EJDB.open._help_}); +Object.defineProperty(dbctl.close, "_help_", {value : EJDB.prototype.close._help_}); +Object.defineProperty(dbctl.status, "_help_", {value : "Get current database status"}); repl.on("exit", function() { dbctl.close(); @@ -68,13 +162,33 @@ function syncdbctx() { repl.resetContext(); if (cdb && cdb.jb) { db.__proto__ = cdb.jb; - db["close"] = dbctl.close.bind(dbctl); - db["status"] = dbctl.status.bind(dbctl); - repl.context.db = db; + db.close = dbctl.close; + db.status = dbctl.status; + db.find = function() { + var ret = cdb.jb.find.apply(cdb.jb, arguments); + if (typeof ret === "object") { + if (!quiet) println("Found " + ret.length + " records"); + for (var i = 0; ret.next() && i < maxInspectRows; ++i) { + println(repl.writer(ret.object())); + } + ret.reset(); + if (ret.length > maxInspectRows) { + if (!quiet) println("Shown only first " + maxInspectRows); + } + if (!quiet) println("\nReturned cursor:"); + } + return ret; + }; + Object.defineProperty(db.find, "_help_", {value : EJDB.prototype.find._help_}); } else { db.__proto__ = dbctl; - repl.context.db = db; } + repl.context.db = db; + repl.context.EJDB = EJDB; +} + +function println(msg) { + repl.outputStream.write(msg + "\n"); } function error(msg) { @@ -82,24 +196,3 @@ function error(msg) { } syncdbctx(); - - - - - - - - - - - - - - - - - - - - - diff --git a/node/clinspect.js b/node/clinspect.js new file mode 100644 index 0000000..e305d05 --- /dev/null +++ b/node/clinspect.js @@ -0,0 +1,370 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +exports.inspect = inspect; + +var error = function(x) { + for (var i = 0, len = arguments.length; i < len; ++i) { + process.stderr.write(arguments[i] + '\n'); + } +}; + +// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics +var colors = { + 'bold' : [1, 22], + 'italic' : [3, 23], + 'underline' : [4, 24], + 'inverse' : [7, 27], + 'white' : [37, 39], + 'grey' : [90, 39], + 'black' : [30, 39], + 'blue' : [34, 39], + 'cyan' : [36, 39], + 'green' : [32, 39], + 'magenta' : [35, 39], + 'red' : [31, 39], + 'yellow' : [33, 39] +}; + +// Don't use 'blue' not visible on cmd.exe +var styles = { + 'special' : 'cyan', + 'number' : 'yellow', + 'boolean' : 'yellow', + 'undefined' : 'grey', + 'null' : 'bold', + 'string' : 'green', + 'date' : 'magenta', + 'help' : 'yellow', + // "name": intentionally not styling + 'regexp' : 'red' +}; + +function stylizeWithColor(str, styleType) { + var style = styles[styleType]; + + if (style) { + return '\u001b[' + colors[style][0] + 'm' + str + + '\u001b[' + colors[style][1] + 'm'; + } else { + return str; + } +} + +function stylizeNoColor(str, styleType) { + return str; +} + + +function inspect(obj, depth, colors) { + var ctx = { + seen : [], + stylize : colors ? stylizeWithColor : stylizeNoColor + }; + return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth)); +} + +function arrayToHash(array) { + var hash = {}; + array.forEach(function(val, idx) { + hash[val] = true; + }); + + return hash; +} + + +function formatValue(ctx, value, recurseTimes) { + // Provide a hook for user-specified inspect functions. + // Check that value is an object with an inspect function on it + if (value && typeof value.inspect === 'function' && + // Filter out the util module, it's inspect function is special + value.inspect !== exports.inspect && + // Also filter out any prototype objects using the circular check. + !(value.constructor && value.constructor.prototype === value)) { + return String(value.inspect(recurseTimes)); + } + + // Primitive types cannot have properties + var primitive = formatPrimitive(ctx, value); + if (primitive) { + return primitive; + } + + // Look up the keys of the object. + var keys = []; + for (var k in value) { + keys.push(k); + } + var visibleKeys = arrayToHash(keys); + + // Some type of object without properties can be shortcutted. + if (keys.length === 0) { + if (typeof value === 'function') { + var name = value.name ? ': ' + value.name : ''; + var ret = ctx.stylize('[Function' + name + ']', 'special'); + if (typeof value._help_ === 'string') { + ret = ret + ' ' + ctx.stylize(value._help_, 'help'); + } + return ret; + } + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } + if (isDate(value)) { + return ctx.stylize(Date.prototype.toString.call(value), 'date'); + } + if (isError(value)) { + return formatError(value); + } + } + + var base = '', array = false, braces = ['{', '}']; + + // Make Array say that they are Array + if (isArray(value)) { + array = true; + braces = ['[', ']']; + } + + // Make functions say that they are functions + if (typeof value === 'function') { + var n = value.name ? ': ' + value.name : ''; + base = ' [Function' + n + ']'; + } + + // Make RegExps say that they are RegExps + if (isRegExp(value)) { + base = ' ' + RegExp.prototype.toString.call(value); + } + + // Make dates with properties first say the date + if (isDate(value)) { + base = ' ' + Date.prototype.toUTCString.call(value); + } + + // Make error with message first say the error + if (isError(value)) { + base = ' ' + formatError(value); + } + + if (keys.length === 0 && (!array || value.length == 0)) { + return braces[0] + base + braces[1]; + } + + if (recurseTimes < 0) { + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } else { + return ctx.stylize('[Object]', 'special'); + } + } + + ctx.seen.push(value); + + var output; + if (array) { + output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); + } else { + output = keys.map(function(key) { + return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); + }); + } + + ctx.seen.pop(); + + return reduceToSingleString(output, base, braces); +} + + +function formatPrimitive(ctx, value) { + switch (typeof value) { + case 'undefined': + return ctx.stylize('undefined', 'undefined'); + + case 'string': + var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') + .replace(/'/g, "\\'") + .replace(/\\"/g, '"') + '\''; + return ctx.stylize(simple, 'string'); + + case 'number': + return ctx.stylize('' + value, 'number'); + + case 'boolean': + return ctx.stylize('' + value, 'boolean'); + } + // For some reason typeof null is "object", so special case here. + if (value === null) { + return ctx.stylize('null', 'null'); + } +} + + +function formatError(value) { + return '[' + Error.prototype.toString.call(value) + ']'; +} + + +function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { + var output = []; + for (var i = 0, l = value.length; i < l; ++i) { + if (hasOwnProperty(value, String(i))) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + String(i), true)); + } else { + output.push(''); + } + } + keys.forEach(function(key) { + if (!key.match(/^\d+$/)) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + key, true)); + } + }); + return output; +} + + +function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { + var name, str, desc; + desc = Object.getOwnPropertyDescriptor(value, key) || { value : value[key] }; + if (desc.get) { + if (desc.set) { + str = ctx.stylize('[Getter/Setter]', 'special'); + } else { + str = ctx.stylize('[Getter]', 'special'); + } + } else { + if (desc.set) { + str = ctx.stylize('[Setter]', 'special'); + } + } + if (!hasOwnProperty(visibleKeys, key)) { + name = '[' + key + ']'; + } + if (!str) { + if (ctx.seen.indexOf(desc.value) < 0) { + if (recurseTimes === null) { + str = formatValue(ctx, desc.value, null); + } else { + str = formatValue(ctx, desc.value, recurseTimes - 1); + } + if (str.indexOf('\n') > -1) { + if (array) { + str = str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n').substr(2); + } else { + str = '\n' + str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n'); + } + } + } else { + str = ctx.stylize('[Circular]', 'special'); + } + } + if (typeof name === 'undefined') { + if (array && key.match(/^\d+$/)) { + return str; + } + name = JSON.stringify('' + key); + if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { + name = name.substr(1, name.length - 2); + name = ctx.stylize(name, 'name'); + } else { + name = name.replace(/'/g, "\\'") + .replace(/\\"/g, '"') + .replace(/(^"|"$)/g, "'"); + name = ctx.stylize(name, 'string'); + } + } + + return name + ': ' + str; +} + + +function reduceToSingleString(output, base, braces) { + var numLinesEst = 0; + var length = output.reduce(function(prev, cur) { + numLinesEst++; + if (cur.indexOf('\n') >= 0) numLinesEst++; + return prev + cur.length + 1; + }, 0); + + if (length > 60) { + return braces[0] + + (base === '' ? '' : base + '\n ') + + ' ' + + output.join(',\n ') + + ' ' + + braces[1]; + } + + return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; +} + + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +function isArray(ar) { + return Array.isArray(ar) || + (typeof ar === 'object' && objectToString(ar) === '[object Array]'); +} +exports.isArray = isArray; + + +function isRegExp(re) { + return typeof re === 'object' && objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + + +function isDate(d) { + return typeof d === 'object' && objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + + +function isError(e) { + return typeof e === 'object' && objectToString(e) === '[object Error]'; +} +exports.isError = isError; + + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + +function pad(n) { + return n < 10 ? '0' + n.toString(10) : n.toString(10); +} + +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + + + + + + diff --git a/node/ejdb.js b/node/ejdb.js index 7c2d7cf..26d3c5a 100644 --- a/node/ejdb.js +++ b/node/ejdb.js @@ -9,7 +9,12 @@ var EJDBImpl = ejdblib.NodeEJDB; const DEFAULT_OPEN_MODE = (ejdblib.JBOWRITER | ejdblib.JBOCREAT); var EJDB = function(dbFile, openMode) { - this._impl = new EJDBImpl(dbFile, (openMode > 0) ? openMode : DEFAULT_OPEN_MODE); + Object.defineProperty(this, "_impl", { + value : new EJDBImpl(dbFile, (openMode > 0) ? openMode : DEFAULT_OPEN_MODE), + configurable : false, + enumerable : false, + writable : false + }); return this; }; @@ -135,7 +140,7 @@ EJDB.prototype.removeCollection = function(cname, prune, cb) { * @param {String} cname Name of collection. * @param {Array|Object} jsarr Signle JSON object or array of JSON objects to save * @param {Function} [cb] Callback function with arguments: (error, {Array} of OIDs for saved objects) - * @return {Array} of OIDs of saved objects in synchronous mode otherwise returns {this}. + * @return {Array} of OIDs of saved objects in synchronous mode otherwise returns {undefined}. */ EJDB.prototype.save = function(cname, jsarr, opts, cb) { if (!jsarr) { @@ -181,7 +186,7 @@ EJDB.prototype.save = function(cname, jsarr, opts, cb) { * @param {String} oid Object identifier (OID) * @param {Function} [cb] Callback function with arguments: (error, obj) * `obj`: Retrieved JSON object or NULL if it is not found. - * @return JSON object or {null} if it is not found in synchronous mode otherwise return {this}. + * @return JSON object or {null} if it is not found in synchronous mode otherwise return {undefined}. */ EJDB.prototype.load = function(cname, oid, cb) { return this._impl.load(cname, oid, cb); @@ -340,7 +345,7 @@ function parseQueryArgs(args) { * @param {Function} [cb] Callback function with arguments: (error, cursor, count) where: * `cursor`: Cursor object to traverse records * `count`: Total number of selected records. - * @return If callback is provided returns {this}. + * @return If callback is provided returns {undefined}. * If no callback and $onlycount hint is set returns count {Number}. * If no callback and no $onlycount hint returns cursor {Object}. * @@ -370,7 +375,7 @@ EJDB.prototype.find = function() { * @param {Object} [hints] JSON object with query hints. * @param {Function} [cb] Callback function with arguments: (error, obj) where: * `obj`: Retrieved JSON object or NULL if it is not found. - * @return If callback is provided returns {this}. + * @return If callback is provided returns {undefined}. * If no callback is provided returns found {Object} or {null}. */ @@ -440,7 +445,7 @@ EJDB.prototype.findOne = function() { * @param {Function} [cb] Callback function with arguments: (error, count) where: * `count`: The number of updated records. * - * @return If callback is provided returns {this}. + * @return If callback is provided returns {undefined}. * If no callback is provided returns {Number} of updated objects. */ EJDB.prototype.update = function() { @@ -478,7 +483,7 @@ EJDB.prototype.update = function() { * @param {Function} [cb] Callback function with arguments: (error, count) where: * `count`: Number of matching records. * - * @return If callback is provided returns {this}. + * @return If callback is provided returns {undefined}. * If no callback is provided returns {Number} of matched object. */ EJDB.prototype.count = function() { diff --git a/node/ejdb_native.cc b/node/ejdb_native.cc index de1938c..1029a54 100644 --- a/node/ejdb_native.cc +++ b/node/ejdb_native.cc @@ -603,7 +603,7 @@ namespace ejdb { if (!njb->close()) { return scope.Close(ThrowException(Exception::Error(String::New(njb->_jb_error_msg())))); } - return scope.Close(args.This()); + return scope.Close(Undefined()); } static Handle<Value> s_load(const Arguments& args) { @@ -625,7 +625,7 @@ namespace ejdb { cb = Local<Function>::Cast(args[2]); BSONCmdTask *task = new BSONCmdTask(cb, njb, cmdLoad, cmdata, BSONCmdTask::delete_val); uv_queue_work(uv_default_loop(), &task->uv_work, s_exec_cmd_eio, s_exec_cmd_eio_after); - return scope.Close(args.This()); + return scope.Close(Undefined()); } else { BSONCmdTask task(cb, njb, cmdLoad, cmdata, BSONCmdTask::delete_val); njb->load(&task); @@ -652,7 +652,7 @@ namespace ejdb { cb = Local<Function>::Cast(args[2]); BSONCmdTask *task = new BSONCmdTask(cb, njb, cmdRemove, cmdata, BSONCmdTask::delete_val); uv_queue_work(uv_default_loop(), &task->uv_work, s_exec_cmd_eio, s_exec_cmd_eio_after); - return scope.Close(args.This()); + return scope.Close(Undefined()); } else { BSONCmdTask task(cb, njb, cmdRemove, cmdata, BSONCmdTask::delete_val); njb->remove(&task); @@ -697,7 +697,7 @@ namespace ejdb { cb = Local<Function>::Cast(args[3]); BSONCmdTask *task = new BSONCmdTask(cb, njb, cmdSave, cmdata, BSONCmdTask::delete_val); uv_queue_work(uv_default_loop(), &task->uv_work, s_exec_cmd_eio, s_exec_cmd_eio_after); - return scope.Close(args.This()); + return scope.Close(Undefined()); } else { BSONCmdTask task(cb, njb, cmdSave, cmdata, BSONCmdTask::delete_val); njb->save(&task); @@ -756,7 +756,7 @@ namespace ejdb { cb = Local<Function>::Cast(args[3]); BSONQCmdTask *task = new BSONQCmdTask(cb, njb, cmdQuery, cmdata, BSONQCmdTask::delete_val); uv_queue_work(uv_default_loop(), &task->uv_work, s_exec_cmd_eio, s_exec_cmd_eio_after); - return scope.Close(args.This()); + return scope.Close(Undefined()); } else { BSONQCmdTask task(cb, njb, cmdQuery, cmdata, BSONQCmdTask::delete_val); njb->query(&task); @@ -787,7 +787,7 @@ namespace ejdb { return scope.Close(Exception::Error(String::New(task.cmd_ret_msg.c_str()))); } } - return scope.Close(args.This()); + return scope.Close(Undefined()); } static Handle<Value> s_sync(const Arguments& args) { @@ -806,7 +806,7 @@ namespace ejdb { return scope.Close(Exception::Error(String::New(task.cmd_ret_msg.c_str()))); } } - return scope.Close(args.This()); + return scope.Close(Undefined()); } static Handle<Value> s_db_meta(const Arguments& args) { @@ -900,7 +900,7 @@ namespace ejdb { if (!coll) { return scope.Close(ThrowException(Exception::Error(String::New(njb->_jb_error_msg())))); } - return scope.Close(args.This()); + return scope.Close(Undefined()); } static Handle<Value> s_rm_collection(const Arguments& args) { @@ -915,7 +915,7 @@ namespace ejdb { RMCollCmdData *cmdata = new RMCollCmdData(*cname, prune->BooleanValue()); RMCollCmdTask *task = new RMCollCmdTask(cb, njb, cmdRemoveColl, cmdata, RMCollCmdTask::delete_val); uv_queue_work(uv_default_loop(), &task->uv_work, s_exec_cmd_eio, s_exec_cmd_eio_after); - return scope.Close(args.This()); + return scope.Close(Undefined()); } static Handle<Value> s_is_open(const Arguments& args) { @@ -1419,7 +1419,7 @@ finish: HandleScope scope; NodeEJDBCursor *c = ObjectWrap::Unwrap< NodeEJDBCursor > (args.This()); c->close(); - return scope.Close(args.This()); + return scope.Close(Undefined()); } static Handle<Value> s_reset(const Arguments& args) { @@ -1427,7 +1427,7 @@ finish: NodeEJDBCursor *c = ObjectWrap::Unwrap< NodeEJDBCursor > (args.This()); c->m_pos = 0; c->m_no_next = true; - return scope.Close(args.This()); + return scope.Close(Undefined()); } static Handle<Value> s_has_next(const Arguments& args) { |