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

waterline

Package Overview
Dependencies
Maintainers
1
Versions
165
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

waterline - npm Package Compare versions

Comparing version 0.5.1 to 0.5.2

test/adapter/caseSensitivity.test.js

17

adapter.js

@@ -339,6 +339,10 @@ var async = require('async');

else {
// Build a list of models
var models = [];
// Create transaction name based on collection
self.transaction(collectionName+'.waterline.default.findOrCreateEach', function (err,done) {
async.forEach(valuesList, function (values,cb) {
async.forEachSeries(valuesList, function (values,cb) {
// Check that each of the criteria keys match:

@@ -351,5 +355,12 @@ // build a criteria query

return self.findOrCreate(collectionName, criteria, values, cb);
return self.findOrCreate(collectionName, criteria, values, function (err, model) {
// Add model to list
if (model) models.push(model);
return cb(err, model);
});
}, done);
},cb);
},function (err) {
// Pass back found/created models
cb(err,models);
});
}

@@ -356,0 +367,0 @@ };

22

package.json
{
"name": "waterline",
"version": "0.5.1",
"version": "0.5.2",
"description": "Active Record for Node.js",

@@ -10,3 +10,3 @@ "main": "waterline.js",

"scripts": {
"test": "mocha --globals ___transaction --recursive --globals User -b -R landing -t 8000"
"test": "node ./node_modules/mocha/bin/mocha --globals ___transaction --recursive --globals User -b -R landing -t 8000"
},

@@ -18,5 +18,6 @@ "repository": {

"keywords": [
"active record",
"active-record",
"activerecord",
"orm",
"model",
"mysql",

@@ -34,11 +35,16 @@ "mongo",

"underscore": "=1.4.3",
"underscore.string": "~2.3.1",
"async": "~0.1.22",
"node-uuid": "~1.4.0",
"fs-extra": "~0.3.2",
"underscore.string": "2.3.1",
"async": "0.1.22",
"node-uuid": "1.4.0",
"fs-extra": "0.3.2",
"require-all": "0.0.5",
"parley": "0.0.2",
"sails-util": "0.1.0",
"sails-moduleloader": "~1.1.5"
"sails-moduleloader": "1.1.5"
},
"devDependencies": {
"waterline-dirty": "~0.4.4",
"mocha": "~1.8.1",
"waterline-mysql": "~0.5.0"
}
}

@@ -18,6 +18,62 @@ /**

describe('findOrCreate()', function () {
var testName = 'findOrCreate([])';
var testData = [
{name: 'marge', type: testName},
{name: 'richie', type: testName},
{name: ''+Math.round(Math.random()*10000), type: testName},
{name: ''+Math.round(Math.random()*10000), type: testName},
{name: ''+Math.round(Math.random()*10000), type: testName},
{name: ''+Math.round(Math.random()*10000), type: testName}
];
before(function (done) {
User.create(testData, done);
});
it ('should create new user(s) for the one that doesn\'t exist', function (cb) {
User.findOrCreateEach(['type','name'],[{
name: 'NOT IN THE SET',
type: testName
}], User.testCount(1, cb));
});
it ('should create properly using shorthand', function (cb) {
User.findOrCreateEach(['type','name'],[{
name: 'ANOTHER ONE NOT IN THE SET',
type: testName
}], User.testCount(1, cb));
});
it ('should NOT create new user(s) for the one that DOES exist', function (cb) {
User.findOrCreateEach(['name'],[{
name: 'richie',
type: testName
},{
name: 'marge',
type: testName
}], function (err, users) {
// console.log(users);
cb();
});
});
// it ('should find existing models properly using shorthand', function (cb) {
// User.findOrCreateEach(['name'],[{
// name: 'richie',
// type: testName
// }, {
// name: 'marge'
// }], User.testCount(2, cb));
// });
});
describe('CRUD :: Aggreagate methods and transactions', function (){
describe ('overloaded usage',function () {
describe ('overloaded usage of create',function () {

@@ -24,0 +80,0 @@ var testName = 'test create a list';

@@ -6,2 +6,31 @@ /*---------------------

var _ = require('underscore');
//////////////////////////////////////////////////
// Testing fns
//
// (these are here purely to make testing easier)
//////////////////////////////////////////////////
exports.testExists = function (exists, cb) {
return function (err, result) {
if(err) return cb(new Error(err));
else if(exists && !result) return cb(new Error('No result was returned, but it should have been.'));
else if(!exists && result) return cb(new Error('Result(s) returned, but it should NOT have been.'));
else cb();
};
};
// find() should return exactly n things
exports.testCount = function (count, cb) {
return function (err, results) {
if(err) return cb(new Error(err));
else if(!results || !_.isArray(results)) return cb(new Error('Results should have been a list, instead it was: '+results+'.'));
else if(results.length !== count) return cb(new Error(results.length+' results were returned, but there should have been '+count+'.'));
else cb();
};
};
// Each CRUD test will set the adapter property to match the adapter being tested

@@ -43,6 +72,6 @@ // exports.adapter = 'dirty';

////////////////////////////////////////////////////////
//exports.adapter = 'waterline-mysql';
//exports.database = 'waterline';
//exports.user = 'waterline';
//exports.password = 'abc123';
// exports.adapter = 'waterline-mysql';
// exports.database = 'waterline';
// exports.user = 'waterline';
// exports.password = 'abc123';

@@ -49,0 +78,0 @@ ////////////////////////////////////////////////////////

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