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.10.0 to 0.11.0

4

lib/Database.js

@@ -53,4 +53,4 @@ !function(){

, executeQuery: function(mode, query, callback) {
this._database.query(mode, query, callback);
, executeQuery: function(configuration) {
this._database.query(configuration);
}

@@ -57,0 +57,0 @@

@@ -22,2 +22,7 @@ !function(){

// should this quer be debugged?
, _debugMode: false
, init: function(options) {

@@ -241,3 +246,3 @@ Class.define(this, '_defintion' , Class(options.definition));

(transaction || this._getDatabase()).executeQuery(query, function(err, data) {
(transaction || this._getDatabase()).executeQuery({query: query, debug: this._debugMode, callback: function(err, data) {
if (err) callback(err);

@@ -256,3 +261,3 @@ else {

}
}.bind(this));
}.bind(this)});

@@ -456,6 +461,6 @@ return this;

else {
transaction.executeQuery('delete', query, function(err){
transaction.executeQuery({mode: 'delete', query: query, debug: this._debugMode, callback: function(err){
if (err) callback(err);
else this._emitEvent('afterDelete', transaction, callback);
}.bind(this));
}.bind(this)});
}

@@ -709,3 +714,3 @@ }.bind(this));

transaction.executeQuery('insert', query, function(err, result) {
transaction.executeQuery({mode: 'insert', query: query, debug: this._debugMode, callback: function(err, result) {
if (err) callback(err);

@@ -755,3 +760,3 @@ else {

}
}.bind(this));
}.bind(this)});
}

@@ -796,6 +801,6 @@ }.bind(this));

// do it
transaction.executeQuery('update', query, function(err) {
transaction.executeQuery({mode: 'update', query: query, debug: this._debugMode, callback: function(err) {
if (err) callback(err);
else this._emitEvent('afterUpdate', transaction, callback);
}.bind(this));
}.bind(this)});
}

@@ -802,0 +807,0 @@ else callback();

@@ -676,3 +676,11 @@ !function(){

/*
* enable query debugger
*/
, debug: function() {
this.getRootResource().debug();
return this;
}
/*

@@ -679,0 +687,0 @@ * execute the query, either using a classic callback or using a promise

@@ -46,3 +46,3 @@ !function(){

// execute the base query
this._executeQuery('query', resource.query, function(err, rows) {
this._executeQuery('query', resource.query, resource, function(err, rows) {
if (err) callback(err);

@@ -67,3 +67,3 @@ else {

this._executeQuery('delete', this._resource.query, callback);
this._executeQuery('delete', this._resource.query, this._resource, callback);
}

@@ -76,3 +76,3 @@

this._executeQuery('update', this._resource.query, callback);
this._executeQuery('update', this._resource.query, this._resource, callback);
}

@@ -87,3 +87,3 @@

this._executeQuery('query', this._resource.query, function(err, result) {
this._executeQuery('query', this._resource.query, this._resource, function(err, result) {
if (err) callback(err);

@@ -114,3 +114,3 @@ else if (result && result.length) callback(null, parseInt(result[0].rowCount, 10));

this._executeQuery('query', resource.query, function(err, rows){
this._executeQuery('query', resource.query, resource, function(err, rows){
if (err) next(err);

@@ -188,4 +188,9 @@ else {

, _executeQuery: function(mode, query, callback) {
(this.transaction || this.getDatabase()).executeQuery(mode, query, callback);
, _executeQuery: function(mode, query, resource, callback) {
(this.transaction || this.getDatabase()).executeQuery({
mode : mode
, query : query
, debug : resource.getRootResoure().isInDebugMode()
, callback : callback
});
}

@@ -192,0 +197,0 @@

@@ -58,2 +58,6 @@ !function () {

// should this quer be debugged?
, _debugMode: false
// indicates for what type of a query the resource is prepared

@@ -135,2 +139,18 @@ , _queryMode: null

/*
* returns the debugmode of this query
*/
, isInDebugMode: function() {
return this._debugMode;
}
/*
* eable debugmode
*/
, debug: function() {
this._debugMode = true;
}
/*
* has a filter?

@@ -137,0 +157,0 @@ */

@@ -132,8 +132,20 @@ !function(){

*/
, executeQuery: function(mode, query, callback) {
, executeQuery: function(configuration) {
var callback;
// did we already get a connection?
if (this._transaction) {
this._transaction.query(mode, query, function(err, results) {
if (debug) this._queries.push({query: query, mode: mode, err: err, errorMessage: err ? err.message : null, results: results});
callback(err, results);
}.bind(this));
// replace original callback for debuggin purposes
if (debug) {
callback = configuration.callback;
configuration.callback = function(err, data) {
if (debug) this._queries.push({query: configuration.query, mode: configuration.mode, err: err, errorMessage: err ? err.message : null, data: data});
callback(err, data);
}.bind(this);
}
// query
this._transaction.query(configuration);
}

@@ -144,7 +156,7 @@ else {

// get a connection
// get a writable connection
this._database.getConnection(false, function(err, connection) {
if (err) {
delete this._queue;
callback(err);
configuration.callback(err);
}

@@ -161,7 +173,7 @@ else {

// work on the queue before executing this one
this._queue.forEach(function(query){
this.executeQuery(query.mode, query.query, query.callback);
this._queue.forEach(function(queryConf) {
this.executeQuery(queryConf);
}.bind(this));
this.executeQuery(mode, query, callback);
this.executeQuery(configuration);
}

@@ -172,7 +184,3 @@ }.bind(this));

// queue connection
this._queue.push({
mode : mode
, query : query
, callback : callback
});
this._queue.push(configuration);
}

@@ -183,2 +191,4 @@ }

, _getDatabase: function() {

@@ -199,3 +209,3 @@ return this;

// models to give them the correct scope ...
Object.keys(database._models).forEach(function(modelName) {
Object.keys(database._models).forEach(function(modelName) {

@@ -221,177 +231,2 @@ // dynamically bind the context

}
/*
module.exports = function(database) {
var transactionInstanceDeifinition
, instance;
transactionInstanceDeifinition = {
// database is an instance of an eventemitter,
// the transaction needs its own events, so we have
// to redefine its storage here.
___events: {
get: function(){
if (!Object.hasOwnProperty.call(this, '____events')) Class.define(this, '____events', Class({}).Writable());
return this.____events;
}
}
// differnet locks that can be obtained by the user on the transaction
// the orm does its best to get a consistent behavior across the different
// rdbms systems, which is sadly not possible with locks.
// see the lock description inside the specific driver
, LOCK_READ: {enumerable: true, value: 'LOCK_READ'}
, LOCK_WRITE: {enumerable: true, value: 'LOCK_WRITE'}
, LOCK_EXCLUSIVE: {enumerable: true, value: 'LOCK_EXCLUSIVE'}
// query logging
, _queries: {value: []}
// query queue
, _queue: {value: []}
// busy flag
// false -> no transaction, need to get one
// true -> busy getting a transaction
// null -> got a transaction
, _busy: {value: null, writable: true}
, isTransaction: {value:function(){
return true;
}}
, getTransaction: {value: function(){
return this;
}}
, commit: {enumerable: true, value: function(callback){
if (this._transaction) {
this._transaction.commit(function(err){
if (!err) this.emit('commit');
if (callback) callback(err);
}.bind(this));
}
else if (this._transaction === false) callback();
else if (callback) callback(new Error('Cannot commit! The transaction has already eneded.'));
this._endTransaction();
}}
, lock: {enumerable: true, value: function(table, mode, callback) {
if (this._transaction) this._transaction.lock(this._databaseName, table, mode, (callback || function(){}));
else if (callback) {
this._lockConfiguration = {
table : table
, mode : mode
};
callback();
}
}}
, rollback: {enumerable: true, value: function(callback){
if (this._transaction) {
if (debug) log.warn('Rolling back transaction, printing query stack:', this._queries);
this._transaction.rollback(function(err){
if (!err) this.emit('rollback');
if (callback) callback(err);
}.bind(this));
}
else if (this._transaction === false) callback();
else if (callback) callback(new Error('Cannot rollback! The transaction has already eneded.'));
this._endTransaction();
}}
, executeQuery: {enumerable: true, value: function(mode, query, callback) {
if (this._transaction) {
this._transaction.query(mode, query, function(err, results) {
if (debug) this._queries.push({query: query, mode: mode, err: err, errorMessage: err ? err.message : null, results: results});
callback(err, results);
}.bind(this));
}
else {
if (!this._busy) {
this._busy = true;
// get a connection
this._database.getConnection(false, function(err, connection) {
if (err) callback(err);
else {
this._busy = null;
this._transaction = connection;
this._transaction.startTransaction();
this._transaction.on('end', this._endTransaction.bind(this));
// check if the table lock must be exexuted
if (this._lockConfiguration) this.lock(this._lockConfiguration.table, this._lockConfiguration.mode, this._lockConfiguration.callback);
// work on the queue before executing this one
this._queue.forEach(function(query){
this.executeQuery(query.mode, query.query, query.callback);
}.bind(this));
this.executeQuery(mode, query, callback);
}
}.bind(this));
}
else {
// queue connection
this._queue.push({
mode : mode
, query : query
, callback : callback
});
}
}
}}
, _getDatabase: { value: function() {
return this;
}}
, _endTransaction: {value: function(){
this._transaction = null;
}}
, _transaction: {value: false, writable:true, configurable: true}
};
// we need to proxy calls on the
// models to give them the correct scope ...
Object.keys(database._models).forEach(function(modelName) {
var ModelConstructor = function(options, relatingSets) {
if (this instanceof ModelConstructor) {
return new database[modelName](instance, options, relatingSets);
}
else {
return database[modelName].apply(instance, Array.prototype.slice.call(arguments));
}
}
transactionInstanceDeifinition[modelName] = {value: ModelConstructor};
}.bind(this));
instance = Object.create(database, transactionInstanceDeifinition);
return instance;
}*/
}();
{
"name" : "ee-orm"
, "description" : "ORM for postgres and mysql. Loads and saves referenced entites, executes complex queries, supports joins, transactions, complex database clusters, connection pooling and much more. No conventions."
, "version" : "0.10.0"
, "description" : "ORM for postgres and mysql. Loads and saves referenced entites, executes complex queries, supports joins, transactions, complex database clusters, connection pooling and much more. No conventions. MIT Licence"
, "version" : "0.11.0"
, "homepage" : "https://github.com/eventEmitter/ee-orm"

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

, "ee-db-cluster" : "0.2.x"
, "ee-mysql-connection" : "^0.4.1"
, "ee-postgres-connection" : "0.6.0"
, "ee-mysql-connection" : "0.5.x"
, "ee-postgres-connection" : "0.8.x"
, "es6-promise" : "2.0.x"

@@ -31,0 +31,0 @@ }

@@ -1,2 +0,2 @@

# ee-orm
# related ORM

@@ -3,0 +3,0 @@ ORM for relational databases.

@@ -24,3 +24,3 @@

db.timeZoneTest('*').find(log);
db.timeZoneTest('*').debug().find(log);

@@ -27,0 +27,0 @@ //return;

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