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

bookshelf-scopes

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bookshelf-scopes - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

.jshintrc

2

package.json
{
"name": "bookshelf-scopes",
"version": "1.0.2",
"version": "1.1.0",
"description": "Giving you Rails like scopes in Bookshelf.js.",

@@ -5,0 +5,0 @@ "main": "src/scopes.js",

@@ -8,3 +8,3 @@ # Bookshelf-Scopes

bookshelf.plugin(scopes);
bookshelf.plugin(require('bookshelf-scopes'));
```

@@ -11,0 +11,0 @@

@@ -7,2 +7,3 @@ 'use strict';

var baseExtend = bookshelf.Model.extend;
var QueryBuilder = bookshelf.knex().constructor;

@@ -15,17 +16,25 @@ bookshelf.Model.extend = function(protoProps) {

self.prototype[property] = function() {
var _this = this;
var passedInArguments = _.toArray(arguments);
return this.query(function(qb) {
passedInArguments.unshift(qb);
self.scopes[property].apply(self.scopes, passedInArguments);
});
if (passedInArguments.length > 0 && passedInArguments[0] instanceof QueryBuilder) {
self.scopes[property].apply(this, passedInArguments);
return self;
} else {
return this.query(function(qb) {
passedInArguments.unshift(qb);
self.scopes[property].apply(_this, passedInArguments);
});
}
};
self[property] = function() {
return this.prototype[property].apply(this, arguments);
}
var model = this.forge();
return model[property].apply(model, arguments);
};
});
return baseExtend.apply(self, arguments);
}
};

@@ -44,5 +53,5 @@ var Model = bookshelf.Model.extend({

self.query(function(qb) {
var args = new Array();
var args = [];
args.push(qb);
self.scopes.default.apply(self.scopes, args);
self.scopes.default.apply(self, args);
});

@@ -62,2 +71,2 @@ }

bookshelf.Model = Model;
}
};
'use strict';
var expect = require('chai').expect;
var scopes = require('../src/scopes');
var Promise = require('bluebird');

@@ -13,3 +12,3 @@

var bookshelf = require('bookshelf')(knex);
bookshelf.plugin(scopes);
bookshelf.plugin(require('../src/scopes'));

@@ -16,0 +15,0 @@ describe('scopes - basic scope', function() {

'use strict';
var expect = require('chai').expect;
var scopes = require('../src/scopes');
var Promise = require('bluebird');

@@ -13,3 +12,3 @@

var bookshelf = require('bookshelf')(knex);
bookshelf.plugin(scopes);
bookshelf.plugin(require('../src/scopes'));

@@ -16,0 +15,0 @@ describe('scopes - default', function() {

'use strict';
var expect = require('chai').expect;
var scopes = require('../src/scopes');
var Promise = require('bluebird');

@@ -13,3 +12,3 @@

var bookshelf = require('bookshelf')(knex);
bookshelf.plugin(scopes);
bookshelf.plugin(require('../src/scopes'));

@@ -16,0 +15,0 @@ describe('scopes - joining scope', function() {

Sorry, the diff of this file is not supported yet

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