Comparing version 0.0.1 to 0.0.2
@@ -9,10 +9,6 @@ const mysql = require('./mysql') | ||
model(tablename, model, exInfo = {}) { | ||
this.tablename = tablename | ||
this.model = model | ||
this.exInfo = exInfo | ||
return this.instance.bind(this) | ||
}, | ||
instance() { | ||
return new Model(this.tablename, this.model, this.exInfo ) | ||
return () => { | ||
return new Model(tablename, model, exInfo) | ||
} | ||
} | ||
} |
@@ -24,3 +24,3 @@ const mysql = require('../mysql') | ||
this.conditions['insert'].forEach(data => { | ||
insertValue.push(`(${Object.values(data).map( d => typeof d === 'string' ? '"' + d + '"' : d).join(',')})`) | ||
insertValue.push(`(${Object.values(data).map( d => mysql.escape(d)).join(',')})`) | ||
}) | ||
@@ -35,3 +35,3 @@ SQL = `insert into ${this.table} (${insertKey}) VALUES ${insertValue.join(',')}` | ||
for (let key in this.conditions['select']) { | ||
conditions.push(`${key} in ( ${typeof this.conditions['select'][key] === 'string' ? '"' + mysql.escape(this.conditions['select'][key]) + '"' : mysql.escape(this.conditions['select'][key]) } )`) | ||
conditions.push(`${key} in ( ${mysql.escape(this.conditions['select'][key]) } )`) | ||
} | ||
@@ -46,7 +46,7 @@ SQL = SQL + `where ${conditions.join(' and ')}` | ||
const updateValue = this.conditions['update'][key] | ||
updateconditions.push(`${key} = ${typeof updateValue === 'string' ? '"' + mysql.escape(updateValue) + '"' : mysql.escape(updateValue) } `) | ||
updateconditions.push(`${key} = ${mysql.escape(updateValue)} `) | ||
} | ||
for (let key in this.conditions['updateWhere']) { | ||
const whereValue = this.conditions['updateWhere'][key] | ||
whereconditions.push(`${key} in ( ${typeof whereValue === 'string' ? '"' + mysql.escape(whereValue) + '"' : mysql.escape(whereValue) } )`) | ||
whereconditions.push(`${key} in ( ${mysql.escape(whereValue)} )`) | ||
} | ||
@@ -53,0 +53,0 @@ SQL = `update ${this.table} set ${updateconditions.join(', ')} where ${whereconditions.join('and')}` |
{ | ||
"name": "h-orm", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"main": "index.js", | ||
"repository": "https://github.com/yuanhaoyu/h-orm.git", | ||
"license": "MIT", | ||
"keywords": [ | ||
"orm", | ||
"mysql", | ||
"database", | ||
"promise", | ||
"easy" | ||
], | ||
"dependencies": { | ||
@@ -8,0 +15,0 @@ "mysql": "^2.17.1" |
@@ -14,2 +14,3 @@ # h-orm | ||
horm.connect({ | ||
limit: 10, | ||
host: '127.0.0.1', | ||
@@ -48,2 +49,3 @@ port: '3306', | ||
{ | ||
limit : 10 // default 10, pool max connect num | ||
host : '127.0.0.1', | ||
@@ -50,0 +52,0 @@ port : '3306', |
@@ -22,3 +22,3 @@ const horm = require('../../index') | ||
horm.connect(mac) | ||
horm.connect(windows) | ||
@@ -25,0 +25,0 @@ const StudentModel = horm.model('teacher', { |
@@ -22,3 +22,3 @@ const horm = require('../../index') | ||
horm.connect(mac) | ||
horm.connect(windows) | ||
@@ -25,0 +25,0 @@ const StudentModel = horm.model('student', { |
@@ -22,3 +22,3 @@ const horm = require('../../index') | ||
horm.connect(mac) | ||
horm.connect(windows) | ||
@@ -25,0 +25,0 @@ const StudentModel = horm.model('teacher', { |
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
162
14374
329