Comparing version 0.2.0 to 0.2.1
@@ -36,3 +36,3 @@ /** | ||
database: s.database || process.env.USER, | ||
poolIdleTimeout: s.poolIdleTimeout || 15000, | ||
poolIdleTimeout: s.poolIdleTimeout || 5000, | ||
poolSize: s.poolSize || s.pool || 25, | ||
@@ -69,3 +69,3 @@ debug: s.debug | ||
var s = schema.settings; | ||
return pg.connect({ | ||
pg.connect({ | ||
host: s.host || 'localhost', | ||
@@ -81,3 +81,3 @@ port: s.port || 5432, | ||
} | ||
return client.query('CREATE DATABASE ' + s.database + ' OWNER ' + s.username + ' ENCODING \'UTF8\'', function (err) { | ||
client.query('CREATE DATABASE ' + s.database + ' OWNER ' + s.username + ' ENCODING \'UTF8\'', function (err) { | ||
if (err) { | ||
@@ -84,0 +84,0 @@ // console.log(err, 'ignoring the error'); |
@@ -114,4 +114,4 @@ /** | ||
self.all(model, {where: filter}, function (err, found) { | ||
if(err || (found && found.length > 1)) { | ||
return callback(err || new Error("Found multiple instances")); | ||
if (err || (found && found.length > 1)) { | ||
return callback(err || new Error("Found multiple instances")); | ||
} | ||
@@ -122,7 +122,7 @@ if (found && found.length === 1) { | ||
obj._initProperties(inst, false); | ||
obj.updateAttributes(data, function(err){ | ||
obj.updateAttributes(data, function (err) { | ||
callback(err, obj); | ||
}); | ||
} else { | ||
Object.keys(filter).forEach(function(key){ | ||
Object.keys(filter).forEach(function (key) { | ||
data[key] = filter[key]; | ||
@@ -308,4 +308,3 @@ }); | ||
var sql = 'SELECT * FROM ' + this.tableEscaped(model); | ||
var self = this; | ||
var queryParams = []; | ||
var self = this, queryParams = []; | ||
@@ -325,15 +324,14 @@ if (filter) { | ||
if (filter.limit) { | ||
sql += ' ' + this.buildLimit(filter.limit, filter.skip || 0); | ||
sql += ' ' + this.buildLimit(filter.limit, filter.offset || filter.skip || 0); | ||
} | ||
} | ||
this.queryAll(sql, queryParams, function (err, data) { | ||
self.queryAll(sql, function (err, data) { | ||
if (err) { | ||
return callback(err, []); | ||
} | ||
callback(null, data.map(function (obj) { | ||
data = data.map(function (obj) { | ||
return self.fromDatabase(model, obj); | ||
})); | ||
}.bind(this)); | ||
return sql; | ||
}.bind(self)); | ||
return callback && callback(null, data); | ||
}.bind(self)); | ||
}; | ||
@@ -400,8 +398,6 @@ | ||
SQLite3.prototype.alterTable = function (model, actualFields, indexes, done, checkOnly) { | ||
var self = this; | ||
var m = self._models[model]; | ||
var self = this, m = self._models[model]; | ||
var defIndexes = m.settings.indexes; | ||
var propNames = Object.keys(m.properties); | ||
var sql = [], isql = []; | ||
var reBuild = false; | ||
var sql = [], isql = [], reBuild = false; | ||
@@ -675,3 +671,3 @@ // change/add new fields | ||
} | ||
}); | ||
}.bind(this)); | ||
@@ -702,4 +698,5 @@ if (primaryKeys.length) { | ||
var p = this._models[model].properties[prop]; | ||
return datatype(p) + ' ' + | ||
(p.allowNull === false || p['null'] === false ? 'NOT NULL' : 'NULL'); | ||
var isDefault = (p.allowNull === false || p['null'] === false ? 'NOT NULL' : 'NULL'); | ||
isDefault = typeof p.default !== 'undefined' ? 'DEFAULT (' + (typeof p.default === 'number' ? p.default : '\'' + p.default + '\'') + ')' : isDefault; | ||
return datatype(p) + ' ' + isDefault; | ||
}; | ||
@@ -731,3 +728,2 @@ | ||
SQLite3.prototype.buildWhere = function buildWhere(conds, adapter, model) { | ||
@@ -820,7 +816,2 @@ var cs = [], or = [], | ||
}); | ||
/* This automatically creates a REGEXP for a string that starts with "/". This is a bad idea when dealing with URL request paths !! | ||
} else if (/^\//gi.test(conds[key])) { | ||
var reg = val.toString().split('/'); | ||
cs.push(keyEscaped + ' REGEXP "' + reg[1] + '"'); | ||
*/ | ||
} else { | ||
@@ -833,4 +824,5 @@ cs.push(keyEscaped + ' = ' + val); | ||
SQLite3.prototype.buildOrderBy = function buildOrderBy(order) { | ||
if (typeof order === 'string') | ||
if (typeof order === 'string') { | ||
order = [order]; | ||
} | ||
return 'ORDER BY ' + order.join(', '); | ||
@@ -837,0 +829,0 @@ }; |
{ | ||
"name": "caminte", | ||
"description": "ORM for every database: redis, mysql, neo4j, mongodb, rethinkdb, postgres, sqlite, tingodb", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"author": { | ||
@@ -100,4 +100,3 @@ "name": "Aleksej Gordejev", | ||
"dependencies": { | ||
"node-uuid": ">= 1.3.3", | ||
"sqlite3": "^3.1.1" | ||
"node-uuid": ">= 1.3.3" | ||
}, | ||
@@ -109,5 +108,7 @@ "devDependencies": { | ||
"coffee-script": "*", | ||
"semicov": "latest", | ||
"should": "latest", | ||
"generic-pool": "latest", | ||
"cradle": ">= 0.6.0", | ||
"felix-couchdb": ">= 1.0.0", | ||
"generic-pool": "latest", | ||
"istanbul": "latest", | ||
@@ -125,4 +126,2 @@ "jshint": "2.x", | ||
"riak-js": ">= 1.0.0", | ||
"semicov": "latest", | ||
"should": "latest", | ||
"sqlite3": "^3.1.1", | ||
@@ -129,0 +128,0 @@ "underscore": "latest" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
696919
13774
- Removedsqlite3@^3.1.1
- Removednan@2.7.0(transitive)
- Removedsqlite3@3.1.13(transitive)