Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

downstairs

Package Overview
Dependencies
Maintainers
3
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

downstairs - npm Package Compare versions

Comparing version 0.3.3 to 0.3.4

11

lib/collection.js

@@ -21,4 +21,11 @@ var Collection = {}

var caller = function(modelCallbackName, _cb){
record.callbacks[modelCallbackName](data, _cb);
var caller = function(invocation, _cb){
if (typeof invocation === "string"){
record.callbacks[invocation](data, _cb);
}
else { //we assume it's an object matching {name: 'callbackName', args: [...]}
invocation.args.push(_cb);
var func = record.callbacks[invocation.name].bind(null, data);
func.apply(null, invocation.args);
}
}

@@ -25,0 +32,0 @@

2

package.json
{
"name": "downstairs",
"description": "A light ORM wrapped about brianc's node-sql and node-pg",
"version": "0.3.3",
"version": "0.3.4",
"homepage": "https://github.com/moneytribeaustralia/downstairs.js",

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

@@ -91,3 +91,2 @@ var Downstairs = require('../lib/downstairs')

describe('defining callbacks on the Model that are run on the Record', function(done){

@@ -99,5 +98,2 @@ beforeEach(function(done) {

it("after find", function(done) {
var pgConnection = new Connection.PostgreSQL(env.connectionString);
Downstairs.add(pgConnection);
var User = Collection.model('User', helper.userConfig);

@@ -124,5 +120,2 @@ var Role = Collection.model('Role', helper.roleConfig);

it("after findAll", function(done) {
var pgConnection = new Connection.PostgreSQL(env.connectionString);
Downstairs.add(pgConnection);
var User = Collection.model('User', helper.userConfig);

@@ -153,4 +146,41 @@ var Role = Collection.model('Role', helper.roleConfig);

});
})
it('with arguments', function(done){
var User = Collection.model('User', helper.userConfig);
var Role = Collection.model('Role', helper.roleConfig);
Role.hasMany(User);
User.belongsTo(Role);
var loadUsers = function(users, roleName, cb){
var f = function(){
if (roleName === 'test'){
this.secretData = {level: 'yellow access'};
} else if (roleName === 'admin'){
this.secretData = {level: 'you see everything as an admin!'};
}
}
async.forEach(users
, function(user, cb2){
f.apply(user);
cb2();
}
, cb)
};
User.when('securityDisplay', loadUsers);
User.create({username: 'donald'}, function(err, user) {
User.findAll({callbacks: [{name: 'securityDisplay', args: ['test']}]}, function(err, users){
users[0].secretData.level.should.equal('yellow access');
User.findAll({callbacks: [{name: 'securityDisplay', args: ['admin']}]}, function(err, users){
users[0].secretData.level.should.equal('you see everything as an admin!');
done();
});
});
});
});
});
describe('defining events on the Model that are run on a Record', function(done){

@@ -161,6 +191,9 @@ beforeEach(function(done) {

it("an event for asynchronously creating a dependent", function(done) {
beforeEach(function(done){
var pgConnection = new Connection.PostgreSQL(env.connectionString);
Downstairs.add(pgConnection);
done();
});
it("an event for asynchronously creating a dependent", function(done) {
var User = Collection.model('User', helper.userConfig);

@@ -183,2 +216,2 @@ var Account = Collection.model('Account', helper.accountConfig);

});
})
});
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