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

sails-mongo

Package Overview
Dependencies
Maintainers
4
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sails-mongo - npm Package Compare versions

Comparing version 0.11.1 to 0.11.2

16

lib/adapter.js

@@ -59,8 +59,8 @@ /*---------------------------------------------------------------

ssl: false,
poolSize: 1,
poolSize: 5,
socketOptions: {
noDelay: false,
noDelay: true,
keepAlive: 0,
connectTimeoutMS: 5000,
socketTimeoutMS: 5000
connectTimeoutMS: 0,
socketTimeoutMS: 0
},

@@ -139,4 +139,8 @@ auto_reconnect: true,

if(!connections[conn]) return cb();
delete connections[conn];
cb();
var dbConnection = connections[conn].connection.db;
dbConnection.close(function () {
delete connections[conn];
cb();
});
},

@@ -143,0 +147,0 @@

@@ -103,3 +103,3 @@

if(err) return cb(err);
cb(null, utils.rewriteIds(docs, self.schema));
cb(null, utils.normalizeResults(docs, self.schema));
});

@@ -359,7 +359,6 @@ };

Collection.prototype._parseDefinition = function _parseDefinition(definition) {
var self = this,
collectionDef = _.cloneDeep(definition);
var self = this;
// Hold the Schema
this.schema = collectionDef.definition;
this.schema = _.cloneDeep(definition.definition);

@@ -366,0 +365,0 @@ if (_.has(this.schema, 'id') && this.schema.id.primaryKey && this.schema.id.type === 'integer') {

@@ -74,6 +74,9 @@

if(_.isString(values.id) && values.id.match(/^[a-fA-F0-9]{24}$/)) {
values.id = new ObjectId.createFromHexString(values.id);
values._id = new ObjectId.createFromHexString(values.id);
} else {
values._id = _.cloneDeep(values.id);
}
values._id = _.cloneDeep(values.id);
delete values.id;

@@ -80,0 +83,0 @@ };

@@ -8,2 +8,3 @@

ObjectId = require('mongodb').ObjectID,
MongoBinary = require('mongodb').Binary,
url = require('url');

@@ -31,3 +32,36 @@

/**
* Re-Write Mongo's _id attribute to a normalized id attribute in single document
*
* @param {Object} models
* @api private
*/
exports._rewriteIds = function(model, schema) {
if (hop.call(model, '_id')) {
// change id to string only if it's necessary
if (typeof model._id === 'object')
model.id = model._id.toString();
else
model.id = model._id;
delete model._id;
}
// Rewrite any foreign keys if a schema is available
if (!schema) return model;
Object.keys(schema).forEach(function (key) {
var foreignKey = schema[key].foreignKey || false;
// If a foreignKey, check if value matches a mongo id and if so turn it into an objectId
if (foreignKey && model[key] instanceof ObjectId) {
model[key] = model[key].toString();
}
});
return model;
};
/**
* Re-Write Mongo's _id attribute to a normalized id attribute

@@ -40,27 +74,25 @@ *

exports.rewriteIds = function rewriteIds(models, schema) {
var _models = models.map(function(model) {
if(hop.call(model, '_id')) {
// change id to string only if it's necessary
if(typeof model._id === 'object')
model.id = model._id.toString();
else
model.id = model._id;
delete model._id;
}
var _models = models.map(function(model){
return exports._rewriteIds(model, schema);
});
return _models;
};
// Rewrite any foreign keys if a schema is available
if(!schema) return model;
/**
* Normalize documents retrieved from MongoDB to match Waterline's expectations
*
* @param {Array} models
* @api public
*/
Object.keys(schema).forEach(function(key) {
var foreignKey = schema[key].foreignKey || false;
// If a foreignKey, check if value matches a mongo id and if so turn it into an objectId
if(foreignKey && model[key] instanceof ObjectId) {
model[key] = model[key].toString();
exports.normalizeResults = function normalizeResults(models, schema) {
var _models = models.map(function (model) {
var _model = exports._rewriteIds(model, schema);
Object.keys(_model).forEach(function (key) {
if (model[key] instanceof MongoBinary && _.has(_model[key], 'buffer')) {
_model[key] = _model[key].buffer;
}
});
return model;
return _model;
});
return _models;

@@ -67,0 +99,0 @@ };

{
"name": "sails-mongo",
"version": "0.11.1",
"version": "0.11.2",
"description": "Mongo DB adapter for Sails.js",

@@ -61,4 +61,7 @@ "main": "./lib/adapter.js",

"associations"
],
"features": [
"cross-adapter"
]
}
}

@@ -25,6 +25,8 @@ /**

var package = {},
interfaces = [];
interfaces = [],
features = [];
try {
package = require('../../package.json');
interfaces = package.waterlineAdapter.interfaces;
features = package.waterlineAdapter.features;
} catch (e) {

@@ -80,6 +82,12 @@ throw new Error(

interfaces: interfaces,
// The set of adapter features to test against.
// (grabbed these from this adapter's package.json file above)
features: features,
// Mocha options
// reference: https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically
mocha: {},
mocha: {
reporter: 'spec'
},

@@ -86,0 +94,0 @@ mochaChainableMethods: {},

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