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

ee-orm

Package Overview
Dependencies
Maintainers
2
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ee-orm - npm Package Compare versions

Comparing version 0.6.21 to 0.7.0

lib/AdvancedQueryBuilder.js

30

lib/ORM.js
!function(){
'use strict';
var Class = require('ee-class')
, log = require('ee-log')
, type = require('ee-types')
, EventEmitter = require('ee-event-emitter')
, argv = require('ee-argv')
, async = require('ee-async')
, DBCluster = require('ee-db-cluster')
, Database = require('./Database')
, StaticORM = require('./StaticORM')
, Set = require('./Set')
, ExtensionManager = require('./ExtensionManager')
, ModelDefinition = require('./ModelDefinition')
, debug = argv.has('debug-sql')
, dev = argv.has('dev-orm')
var Class = require('ee-class')
, log = require('ee-log')
, type = require('ee-types')
, EventEmitter = require('ee-event-emitter')
, argv = require('ee-argv')
, async = require('ee-async')
, DBCluster = require('ee-db-cluster')
, Database = require('./Database')
, StaticORM = require('./StaticORM')
, Set = require('./Set')
, ExtensionManager = require('./ExtensionManager')
, ModelDefinition = require('./ModelDefinition')
, debug = argv.has('debug-sql')
, dev = argv.has('dev-orm')
, staticORM

@@ -127,3 +127,5 @@ , ORM;

/*

@@ -130,0 +132,0 @@ * initializtes the orm, reads the db definition, checks if for relations

@@ -59,2 +59,3 @@ !function(){

, primaryKeys : this._definition.primaryKeys
, queryBuilder : this
, query : new Query({

@@ -83,4 +84,35 @@ from: this.tableName

/*
* return a new advanced querybuilder instance
*/
, createQueryBuilder: function() {
return ORM.createQueryBuilder(this);
}
/*
* register an advanced query builder on this object
*/
, setQueryBuilder: function(qb) {
if (!this.getRootResource().advancedQueryQuerybuilders)this.getRootResource().advancedQueryQuerybuilders = [];
this.getRootResource().advancedQueryQuerybuilders.push(qb);
}
/*
* return a new advanced querybuilder instance
*/
, qb: function() {
return this.createQueryBuilder();
}
/*
* return a new advanced querybuilder instance
*/
, queryBuilder: function() {
return this.createQueryBuilder();
}
, parseFilter: function(parameters) {

@@ -87,0 +119,0 @@ this._parseFilter(this._resource.query, this.tableName, this._getFilters(parameters));

@@ -264,5 +264,5 @@ !function(){

classDefinition.join = Class(function(targetName) {
classDefinition.join = Class(function(targetName, returnTarget) {
if (Object.hasOwnProperty.call(accessorMap.join, targetName)) {
return accessorMap.join[targetName].apply(this, Array.prototype.slice.call(arguments, 1));
return accessorMap.join[targetName].apply(this, Array.prototype.slice.call(arguments, 1), !!returnTarget);
} else throw new Error('The QueryBuilder has no property «'+targetName+'»!');

@@ -269,0 +269,0 @@ }).Enumerable();

@@ -87,2 +87,3 @@ !function () {

this.loaderId = options.loaderId;
this.queryBuilder = options.queryBuilder;

@@ -127,3 +128,13 @@

/*
* return the filter object
*/
, getFilter: function() {
return this.filters;
}
/*
* merge filter object

@@ -236,2 +247,5 @@ */

// check for advanced query builders, invoke them on myself
this._invokeAdvancedQueryBuilders();
// we need the primary keys on the root query

@@ -253,2 +267,17 @@ if (!isSubQuery) this.selectPrimaryKeys();

/*
* invoke advanced query builders o that they can apply
* their filters to the query
*/
, _invokeAdvancedQueryBuilders: function() {
if (this.advancedQueryQuerybuilders) {
this.advancedQueryQuerybuilders.forEach(function(qb) {
qb.apply(this.query.filter, this.queryBuilder);
}.bind(this));
log(this.filters);
}
}
/*
* check which children must be selected. this means to select

@@ -255,0 +284,0 @@ * all parents if required.

!function(){
var Class = require('ee-class')
, log = require('ee-log')
, type = require('ee-types')
, Model = require('./Model');
var Class = require('ee-class')
, log = require('ee-log')
, type = require('ee-types')
, Model = require('./Model')
, AdvancedQueryBuilder = require('./AdvancedQueryBuilder');

@@ -165,3 +166,24 @@

/*
* return a new advanced querybuilder instance
*/
, createQueryBuilder: function(query) {
return new AdvancedQueryBuilder(query);
}
/*
* return a new advanced querybuilder instance
*/
, qb: function(query) {
return new AdvancedQueryBuilder(query);
}
/*
* return a new advanced querybuilder instance
*/
, queryBuilder: function(query) {
return new AdvancedQueryBuilder(query);
}
// the model, needed for extending models

@@ -168,0 +190,0 @@ , Model: Model

{
"name" : "ee-orm"
, "description" : "An easy to use ORM for node.js. Supports eager loading, complex queries, joins, transactions, complex database clusters & connection pooling."
, "version" : "0.6.21"
, "version" : "0.7.0"
, "homepage" : "https://github.com/eventEmitter/ee-orm"

@@ -6,0 +6,0 @@ , "author" : "Michael van der Weg <michael@eventemitter.com> (http://eventemitter.com/)"

@@ -26,7 +26,19 @@

db.event(['*']).getVenue(['*']).findOne(function(err, item) {
log(err, item);
})
var query = db.event(['*'])
, qb = query.queryBuilder();
qb.and({
id: ORM.gt(0)
}
, qb.or({
'venue.name': ORM.like('re%')
, 'venue.id_image': 5
})
);
query.find(log);
});
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