New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

entree

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

entree - npm Package Compare versions

Comparing version 0.0.1-beta-1 to 0.0.2

test/manager.js

3

lib/entree.js
/*jslint plusplus: true, devel: true, nomen: true, vars: true, node: true, indent: 4, maxerr: 50 */
/*global require, exports, module */

@@ -8,2 +7,2 @@ exports.Manager = require("./manager");

exports.Cursor = require("./cursor");
exports.Cursor = require("./cursor");

@@ -120,4 +120,10 @@ /*jslint plusplus: true, devel: true, nomen: true, vars: true, node: true, sloppy: true, es5: true, indent: 4, maxerr: 50 */

Provider.prototype.dispose = function () {
Provider.prototype.init = function (callback) {
// Override if you need to initialize database connection.
callback();
};
Provider.prototype.dispose = function (callback) {
// Override if you need to dispose database connection.
callback();
};

@@ -124,0 +130,0 @@

@@ -172,4 +172,4 @@ /*jslint node: true, plusplus: true, devel: true, nomen: true, vars: true, es5: true, indent: 4, maxerr: 50 */

if (options) {
if (options.typeName) {
path = url.resolve(path, options.typeName);
if (options.name) {
path = url.resolve(path, options.name);
}

@@ -176,0 +176,0 @@ this._reqOpts = url.parse(path);

@@ -152,4 +152,5 @@ /*jslint node: true, plusplus: true, devel: true, nomen: true, vars: true, indent: 4, maxerr: 50 */

if (options && options.typeName) {
this.dir = path.join(connStr, options.typeName);
connStr = path.resolve(process.cwd(), connStr);
if (options && options.name) {
this.dir = path.join(connStr, options.name);
} else {

@@ -162,3 +163,3 @@ this.dir = connStr;

process.chdir(connStr);
fs.mkdirSync(options.typeName);
fs.mkdirSync(options.name);
process.chdir(orgCwd);

@@ -165,0 +166,0 @@ }

@@ -16,3 +16,3 @@ /*jslint node: true, plusplus: true, devel: true, nomen: true, vars: true, es5: true, indent: 4, maxerr: 50 */

var connStr = prov.connectionString,
collName = prov.options.typeName,
collName = prov.options.name,
mdb = _conns[connStr];

@@ -60,28 +60,21 @@

var that = this;
that.provider._init(function (err, coll) {
if (err) {
throw err;
var opts = {};
if (this.mapping) {
if (_.isFunction(this.mapping)) {
this._mapFunc = true;
} else {
opts.fields = this.mapping;
}
var opts = {};
if (that.mapping) {
if (_.isFunction(that.mapping)) {
this._mapFunc = true;
} else {
opts.fields = that.mapping;
}
}
if (that.criteria) {
opts.sort = that.criteria;
}
if (that.limitValue !== 0) {
opts.limit = that.limitValue;
}
if (that.skipValue !== 0) {
opts.skip = that.skipValue;
}
that._cursor = coll.find(that.query, opts);
callback(that._cursor);
});
}
if (this.criteria) {
opts.sort = this.criteria;
}
if (this.limitValue !== 0) {
opts.limit = this.limitValue;
}
if (this.skipValue !== 0) {
opts.skip = this.skipValue;
}
this._cursor = this.provider.collection.find(this.query, opts);
callback(this._cursor);
};

@@ -231,9 +224,3 @@

this.provider._init(function (err, coll) {
if (err) {
return callback(err);
}
coll.update(select, { $set: data }, opts, callback);
});
this.provider.collection.update(select, { $set: data }, opts, callback);
};

@@ -248,9 +235,3 @@

this.provider._init(function (err, coll) {
if (err) {
return callback(err);
}
coll.remove(select, opts, callback);
});
this.provider.collection.remove(select, opts, callback);
};

@@ -287,6 +268,3 @@

MongoProvider.prototype._init = function (callback) {
if (this.collection) {
return callback(null, this.collection);
}
MongoProvider.prototype.init = function (callback) {
var that = this;

@@ -297,8 +275,9 @@ getCollection(this, function (err, coll) {

}
callback(err, coll);
callback(err);
});
};
MongoProvider.prototype.dispose = function () {
MongoProvider.prototype.dispose = function (callback) {
removeReference(this);
callback();
};

@@ -309,17 +288,11 @@

this._init(function (err, coll) {
if (err) {
return callback(err);
this.collection.insert(items, opts, function (err, result) {
var res;
if (_.isArray(items)) {
res = result;
} else if (result && result.length === 1) {
res = result[0];
}
coll.insert(items, opts, function (err, result) {
var res;
if (_.isArray(items)) {
res = result;
} else if (result && result.length === 1) {
res = result[0];
}
callback(err, res);
});
callback(err, res);
});

@@ -336,9 +309,3 @@ };

this._init(function (err, coll) {
if (err) {
return callback(err);
}
coll.update(select, item, opts, callback);
});
this.collection.update(select, item, opts, callback);
};

@@ -357,9 +324,3 @@

this._init(function (err, coll) {
if (err) {
return callback(err);
}
coll.remove(select, opts, callback);
});
this.collection.remove(select, opts, callback);
};

@@ -370,13 +331,7 @@

this._init(function (err, coll) {
if (err) {
return callback(err);
this.collection.findOne(select, function (err, result) {
if (!err && !result) {
err = new Error(Strings.ITEM_DOESNOT_EXIST);
}
coll.findOne(select, function (err, result) {
if (!err && !result) {
err = new Error(Strings.ITEM_DOESNOT_EXIST);
}
callback(err, result);
});
callback(err, result);
});

@@ -383,0 +338,0 @@ };

@@ -16,5 +16,8 @@ /*jslint plusplus: true, devel: true, nomen: true, vars: true, node: true, indent: 4, maxerr: 50 */

"MISSING_ID" : "Identifier not specified.",
"MISSING_CONN_STR" : "Missing connStr (connection string) argument."
"MISSING_CONN_STR" : "Missing connStr (connection string) argument.",
"MISSING_CONF_PROV" : "Cofiguration provider must be specified (config.provider).",
"MISSING_CONF_FOR_ENV" : "There is no configuration for environment \"%s\".",
"NO_PROVIDERS" : "No providers configured for environment \"%s\". "
};
module.exports = strings;
{
"name" : "entree",
"description" : "Data provider model abstraction.",
"version" : "0.0.1-beta-1",
"version" : "0.0.2",
"main" : "index",

@@ -6,0 +6,0 @@ "scripts" : {

@@ -158,2 +158,11 @@ /*jslint plusplus: true, devel: true, nomen: true, vars: true, node: true, es5: true, indent: 4, maxerr: 50 */

function initProvider() {
provider.init(function (err) {
if (err) {
throw err;
}
test.done();
});
}
if (init) {

@@ -164,6 +173,6 @@ init(function (err) {

}
test.done();
initProvider();
});
} else {
test.done();
initProvider();
}

@@ -729,6 +738,10 @@ },

test.expect(0);
provider.dispose();
test.done();
provider.dispose(function (err) {
if (err) {
throw err;
}
test.done();
});
}
});
};

@@ -11,3 +11,3 @@ /*jslint plusplus: true, devel: true, nomen: true, vars: true, node: true, indent: 4, maxerr: 50 */

options = {
typeName: "blogs",
name: "blogs",
identifier: "_id"//,

@@ -18,3 +18,3 @@ //authorization: "MasterKey PqmmvlWWBF5svReW7p3mkYG9X61nus1w"

function init(callback) {
var opts = url.parse(url.resolve(connStr, options.typeName)),
var opts = url.parse(url.resolve(connStr, options.name)),
req;

@@ -21,0 +21,0 @@

@@ -29,3 +29,3 @@ /*jslint node: true, plusplus: true, devel: true, nomen: true, vars: true, es5: true, indent: 4, maxerr: 50 */

var connStr = __dirname + "/data",
options = { typeName: "blogs" };
options = { name: "blogs" };

@@ -32,0 +32,0 @@ context = {

@@ -8,13 +8,13 @@ /*jslint plusplus: true, devel: true, nomen: true, vars: true, node: true, indent: 4, maxerr: 50 */

connStr = __dirname + "/data",
options = { typeName: "blogs", identifier: "_id", option: 1, foo: "bar" },
options = { name: "blogs", identifier: "_id", option: 1, foo: "bar" },
wrench = require("wrench"),
fs = require("fs");
fs = require("fs"),
path = connStr + "/blogs";
if (fs.existsSync(connStr)) {
wrench.rmdirSyncRecursive(connStr);
if (!fs.existsSync(connStr)) {
fs.mkdirSync(connStr);
} else {
fs.mkdirSync(connStr);
} else if (fs.existsSync(path)) {
wrench.rmdirSyncRecursive(path);
}
module.exports = testCase.getTestCase(provider, connStr, options);

@@ -20,3 +20,4 @@ /*jslint plusplus: true, devel: true, nomen: true, node: true, es5: true, indent: 4, maxerr: 50 */

"./el-common.js",
"./mo-common.js"
"./mo-common.js",
"./manager.js"
]);

@@ -9,3 +9,3 @@ /*jslint plusplus: true, devel: true, nomen: true, vars: true, node: true, indent: 4, maxerr: 50 */

options = {
typeName: "blogs",
name: "blogs",
identifier: "_id"

@@ -24,3 +24,3 @@ },

}
db.collection(options.typeName).drop(function (err) {
db.collection(options.name).drop(function (err) {
db.close();

@@ -27,0 +27,0 @@ if (err && err.message !== "ns not found") {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc