json-schema-table
Advanced tools
Comparing version 0.1.1 to 0.1.2
{ | ||
"name": "json-schema-table", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Creates and maintains a SQL table structure", | ||
@@ -33,3 +33,3 @@ "homepage": "", | ||
"mssql": "^2.1.8", | ||
"pg-promise": "^1.8.5", | ||
"pg": "^4.4.1", | ||
"pretty-hrtime": "^1.0.0" | ||
@@ -36,0 +36,0 @@ }, |
@@ -518,3 +518,3 @@ var _ = require('lodash'); | ||
case 'number': | ||
if (property.decimals) { | ||
if (property.decimals && property.decimals > 0) { | ||
column = 'NUMERIC(' + property.maxLength + ',' + property.decimals + ')'; | ||
@@ -684,7 +684,20 @@ } else { | ||
//log('execute', command); | ||
return db.none(command); | ||
return this.query(command); | ||
}, | ||
query: function(command) { | ||
//log('query', command); | ||
return db.query(command); | ||
return new Promise(function(resolve, reject) { | ||
db.connect(function(err, client, done) { | ||
if (err) return reject(err); | ||
client.query(command, function(err, result) { | ||
if (err) { | ||
done(); | ||
reject(err); | ||
return; | ||
} | ||
done(); | ||
resolve(result.rows); | ||
}); | ||
}); | ||
}); | ||
} | ||
@@ -716,3 +729,3 @@ }; | ||
function isPostgres(db) { | ||
return db.oneOrNone !== void 0; //todo identify in a better way | ||
return typeof db.defaults === 'object'; //todo identify in a better way | ||
} | ||
@@ -719,0 +732,0 @@ |
30068
727