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.2.0 to 1.2.1

2

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

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

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

module.exports = function(bookshelf) {
var base = bookshelf.Model;
var baseExtend = bookshelf.Model.extend;

@@ -11,3 +12,3 @@ // `bookshelf.knex()` was deprecated in knex v0.8.0, use `knex.queryBuilder()` instead if available

bookshelf.Model.extend = function(protoProps) {
bookshelf.Model.extend = function(protoProps, constructorProps) {
var model = baseExtend.apply(this, arguments);

@@ -47,7 +48,9 @@

var relationship = original.apply(this, arguments);
if (relationship.model.prototype.scopes && relationship.model.prototype.scopes.default) {
var target = relationship.model || relationship.relatedData.target;
if (target.prototype.scopes && target.prototype.scopes.default) {
var originalSelectConstraints = relationship.relatedData.selectConstraints;
relationship.relatedData.selectConstraints = function(knex, options) {
originalSelectConstraints.apply(this, arguments);
relationship.model.prototype.scopes.default.apply(this, [knex]);
target.prototype.scopes.default.apply(this, [knex]);
};

@@ -75,5 +78,3 @@ }

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

@@ -80,0 +81,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