Comparing version 0.3.7 to 0.4.0
/** | ||
* Module dependencies | ||
*/ | ||
var Bluebird = require("bluebird"); | ||
var Bluebird = require('bluebird'); | ||
var vld = require('./validatable'); | ||
@@ -36,3 +36,3 @@ var hkb = require('./hookable'); | ||
if (!Object.prototype.hasOwnProperty('extend')) { | ||
Object.defineProperty(Object.prototype, "extend", { | ||
Object.defineProperty(Object.prototype, 'extend', { | ||
enumerable: false, | ||
@@ -163,3 +163,3 @@ writable: true, | ||
this.trigger("initialize"); | ||
this.trigger('initialize'); | ||
}; | ||
@@ -326,3 +326,2 @@ | ||
if (stillConnecting(this.schema, this, arguments)) { | ||
console.log('++++ stillConnecting') | ||
return; | ||
@@ -329,0 +328,0 @@ } |
@@ -25,18 +25,16 @@ /** | ||
s.database = s.database || 'test'; | ||
if (!schema.settings.url) { | ||
var durl = schema.settings.host || 'localhost'; | ||
if (schema.settings.port) | ||
durl += ':' + schema.settings.port; | ||
var auth = ''; | ||
if (schema.settings.username) { | ||
if (!('url' in schema.settings)) { | ||
schema.settings.url = ''; | ||
let durl = 'http://'; | ||
let auth = ''; | ||
if('username' in schema.settings){ | ||
auth = schema.settings.username; | ||
if (schema.settings.password) { | ||
auth += ':' + schema.settings.password; | ||
} | ||
if('password' in schema.settings) | ||
auth += ':'+schema.settings.password; | ||
auth += '@'; | ||
} | ||
if (auth) { | ||
durl = auth + '@' + url; | ||
} | ||
durl += '/'; | ||
durl = 'http://' + durl; | ||
durl += auth+s.host+":"+s.port+"/"; | ||
schema.settings.url = durl; | ||
@@ -43,0 +41,0 @@ } |
@@ -135,9 +135,11 @@ /** | ||
MongoDB.prototype.collection = function (name) { | ||
var collection = this._models[name].settings.collection || name; | ||
if (this.client.collection) { | ||
return this.client.collection(name); | ||
return this.client.collection(collection); | ||
} else { | ||
if (!this.collections[name]) { | ||
this.collections[name] = new mongodb.Collection(this.client, name); | ||
if (!this.collections[collection]) { | ||
this.collections[collection] = new mongodb.Collection(this.client, collection); | ||
} | ||
return this.collections[name]; | ||
return this.collections[collection]; | ||
} | ||
@@ -144,0 +146,0 @@ }; |
@@ -68,3 +68,3 @@ /** | ||
if (error.code !== 'PROTOCOL_CONNECTION_LOST') throw error; | ||
console.log("> Re-connecting lost MySQL connection: " + error.stack); | ||
console.log('> Re-connecting lost MySQL connection: ' + error.stack); | ||
if (s.pool) { | ||
@@ -215,6 +215,6 @@ schema.client = mysql.createPool(conSettings); | ||
'use strict'; | ||
var self = this, sql = "", keyName = params.name || null, afld = [], kind = ""; | ||
var self = this, sql = '', keyName = params.name || null, afld = [], kind = ''; | ||
Object.keys(fields).forEach(function (field) { | ||
if (!keyName) { | ||
keyName = "idx_" + field; | ||
keyName = 'idx_' + field; | ||
} | ||
@@ -224,3 +224,3 @@ afld.push('`' + field + '`'); | ||
if (params.unique) { | ||
kind = "UNIQUE"; | ||
kind = 'UNIQUE'; | ||
} | ||
@@ -288,6 +288,6 @@ // CREATE INDEX IF NOT EXISTS xi ON xx5 (x); | ||
if ('function' === typeof filter) { | ||
return filter(new Error("Get parametrs undefined"), null); | ||
return filter(new Error('Get parametrs undefined'), null); | ||
} | ||
if ('function' === typeof data) { | ||
return data(new Error("Set parametrs undefined"), null); | ||
return data(new Error('Set parametrs undefined'), null); | ||
} | ||
@@ -401,3 +401,3 @@ filter = filter.where ? filter.where : filter; | ||
} | ||
if (prop.type.name === "Boolean") { | ||
if (prop.type.name === 'Boolean') { | ||
return val ? 1 : 0; | ||
@@ -420,3 +420,3 @@ } | ||
} | ||
if ((props[key].type.name || '').toString().toLowerCase() === 'json' && typeof val == "string") { | ||
if ((props[key].type.name || '').toString().toLowerCase() === 'json' && typeof val == 'string') { | ||
try { | ||
@@ -616,5 +616,5 @@ val = JSON.parse(val); | ||
} | ||
if ((indexNames.indexOf(indexName) === -1 && !m.properties[indexName]) | ||
|| ((m.properties[indexName] && !m.properties[indexName].index) | ||
&& (m.properties[indexName] && !m.properties[indexName].unique))) { | ||
if ((indexNames.indexOf(indexName) === -1 && !m.properties[indexName]) || | ||
((m.properties[indexName] && !m.properties[indexName].index) && | ||
(m.properties[indexName] && !m.properties[indexName].unique))) { | ||
sql.push('DROP INDEX `' + indexName + '`'); | ||
@@ -709,3 +709,2 @@ } else { | ||
function actualize(propName, oldSettings) { | ||
'use strict'; | ||
var newSettings = m.properties[propName]; | ||
@@ -718,3 +717,2 @@ if (newSettings && changed(newSettings, oldSettings)) { | ||
function changed(newSettings, oldSettings) { | ||
'use strict'; | ||
if (oldSettings.Null === 'YES' && (newSettings.allowNull === false || newSettings.null === false)) { | ||
@@ -721,0 +719,0 @@ return true; |
@@ -21,7 +21,7 @@ exports.Hookable = Hookable; | ||
var capitalizedName = capitalize(actionName); | ||
var afterHook = this.constructor["after" + capitalizedName]; | ||
var beforeHook = this.constructor["before" + capitalizedName]; | ||
var afterHook = this.constructor['after' + capitalizedName]; | ||
var beforeHook = this.constructor['before' + capitalizedName]; | ||
var inst = this; | ||
// we only call "before" hook when we have actual action (work) to perform | ||
// we only call 'before' hook when we have actual action (work) to perform | ||
if (work) { | ||
@@ -52,2 +52,2 @@ if (beforeHook) { | ||
return string.charAt(0).toUpperCase() + string.slice(1); | ||
} | ||
} |
@@ -65,3 +65,3 @@ /* | ||
if (/^-/.test(key)) { | ||
this.q.params[method] = key.replace(/^-/, "") + ' DESC'; | ||
this.q.params[method] = key.replace(/^-/, '') + ' DESC'; | ||
} else { | ||
@@ -198,2 +198,2 @@ this.q.params[method] = key; | ||
module.exports = exports = Query; | ||
module.exports = exports = Query; |
@@ -53,3 +53,3 @@ /** | ||
name = name ? name.toLowerCase() : ""; | ||
name = name ? name.toLowerCase() : ''; | ||
switch (name) { | ||
@@ -56,0 +56,0 @@ case 'sqlite': |
@@ -187,3 +187,3 @@ module.exports = BaseSQL; | ||
// TODO | ||
// sql = 'PRAGMA encoding = "UTF-8"; ' + sql; | ||
// sql = 'PRAGMA encoding = 'UTF-8'; ' + sql; | ||
} else if (self.name === 'cassandra') { | ||
@@ -190,0 +190,0 @@ // add sorting indexes |
@@ -60,3 +60,3 @@ exports.inherits = function(newClass, baseClass) { | ||
if (hasOrder) { | ||
if (hasOrder[1] === "DE") { | ||
if (hasOrder[1] === 'DE') { | ||
return -1; | ||
@@ -76,3 +76,3 @@ } | ||
stripOrder: function(key) { | ||
return key.replace(/\s+(A|DE)SC/i, ""); | ||
return key.replace(/\s+(A|DE)SC/i, ''); | ||
}, | ||
@@ -79,0 +79,0 @@ savePrep: function(data) { |
@@ -25,3 +25,3 @@ exports.Validatable = Validatable; | ||
* | ||
* Default error message "can't be blank" | ||
* Default error message 'can't be blank' | ||
* | ||
@@ -28,0 +28,0 @@ * @example presence of title |
{ | ||
"name": "caminte", | ||
"description": "ORM for every database: redis, mysql, neo4j, mongodb, rethinkdb, postgres, sqlite, tingodb", | ||
"version": "0.3.7", | ||
"version": "0.4.0", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Aleksej Gordejev", |
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
709909
14325