mysql-wrap-production
Advanced tools
Comparing version 0.7.2 to 0.7.3
{ | ||
"mysql": { | ||
"host": "127.0.0.1", | ||
"user": "admin", | ||
"password": "admin", | ||
"user": "root", | ||
"password": "password", | ||
"database": "mysql-test" | ||
} | ||
} |
module.exports = function (grunt) { | ||
grunt.initConfig({ | ||
mochaTest: { | ||
all: { | ||
// options: { reporter: 'dot' }, | ||
src: ['test/**/*.js'] | ||
} | ||
all: { src: ['test/**/*.js'] } | ||
} | ||
@@ -9,0 +6,0 @@ }); |
{ | ||
"name": "mysql-wrap-production", | ||
"version": "0.7.2", | ||
"version": "0.7.3", | ||
"description": "Mysql interface and helper functions, wrapping node-mysql", | ||
@@ -34,4 +34,5 @@ "main": "src/mysql-wrap.js", | ||
"lodash": "^3.10.1", | ||
"q": "^1.4.1" | ||
"q": "^1.4.1", | ||
"squel": "^5.4.2" | ||
} | ||
} |
'use strict'; | ||
let _ = require('lodash'); | ||
let Q = require('q'); | ||
const _ = require('lodash'); | ||
const Q = require('q'); | ||
const squel = require('squel'); | ||
@@ -11,2 +12,5 @@ Q.longStackSupport = true; | ||
// let self = function () { | ||
// console.log('called'); | ||
// }; | ||
let self = {}; | ||
@@ -128,2 +132,29 @@ | ||
self.build = () => { | ||
const wrap = method => { | ||
return () => { | ||
let s = squel[method]({ | ||
autoQuoteTableNames: true, | ||
autoQuoteFieldNames: true | ||
}); | ||
s.run = () => { | ||
let p = s.toParam(); | ||
return self.query(p.text, p.values); | ||
}; | ||
return s; | ||
}; | ||
}; | ||
let buildSelf = { | ||
select: wrap('select'), | ||
update: wrap('update'), | ||
delete: wrap('delete'), | ||
insert: wrap('insert') | ||
}; | ||
return buildSelf; | ||
}; | ||
self.query = function (statementRaw, values) { | ||
@@ -130,0 +161,0 @@ let statementObject = getStatementObject(statementRaw); |
'use strict'; | ||
let _ = require('lodash'); | ||
let Q = require('q'); | ||
let chai = require('chai'); | ||
let config = require('../config'); | ||
let mysql = require('mysql'); | ||
let createNodeMySQL = require('../src/mysql-wrap'); | ||
const _ = require('lodash'); | ||
const Q = require('q'); | ||
const chai = require('chai'); | ||
const config = require('../config'); | ||
const mysql = require('mysql'); | ||
const createNodeMySQL = require('../src/mysql-wrap'); | ||
@@ -54,2 +54,12 @@ describe('mysqlWrap', function () { | ||
describe('build', function () { | ||
it('should return query generator', function (done) { | ||
this.sql.build().select().from('table').where('field = ?', 'bar').run() | ||
.then(resp => { | ||
chai.assert.deepEqual(resp, [this.b]); | ||
done(); | ||
}).done(); | ||
}); | ||
}); | ||
describe('queryStream', function () { | ||
@@ -56,0 +66,0 @@ it('should return a readable stream of rows', function (done) { |
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
39832
796
3
13
+ Addedsquel@^5.4.2
+ Addedsquel@5.13.0(transitive)