Skip to content

Commit

Permalink
mysql fix getDBObject
Browse files Browse the repository at this point in the history
  • Loading branch information
mideveloper committed May 8, 2014
1 parent b9b0ec8 commit 692737f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/models/mysql.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ function initialize(params) {

Model.prototype.save = function save() {
var self = this;
return _knex.raw(getInsertSQL(self, self.input));
return _knex.raw(getInsertSQL(self, self.getDBObject(self.input)));
};

Model.prototype.saveInBatch = function saveInBatch() {
var self = this;
var batch_statement = "";

for (var index = 0; index < self.input.length; index++) {
batch_statement += getInsertSQL(self, self.input[index]);
batch_statement += getInsertSQL(self, self.getDBObject(self.input[index]));
}

return _knex.raw(batch_statement);
Expand All @@ -167,7 +167,7 @@ function initialize(params) {
var self = this;
if (arguments.length > 0) {

return _knex(self.tableName).where(self.input).select(_.toArray(arguments)).then(function(obj) {
return _knex(self.tableName).where(self.getDBObject(self.input)).select(_.toArray(arguments)).then(function(obj) {
if (obj.length > 0) {
return self.getObjectFromDBObject(obj.shift());
}else{
Expand All @@ -176,7 +176,7 @@ function initialize(params) {
});
}
else {
return _knex(self.tableName).where(self.input).select().then(function(obj) {
return _knex(self.tableName).where(self.getDBObject(self.input)).select().then(function(obj) {
if (obj.length > 0) {
return self.getObjectFromDBObject(obj.shift());
}else{
Expand All @@ -190,7 +190,7 @@ function initialize(params) {
Model.prototype.getInBatch = function getInBatch() {
var self = this;
var result = [];
return _knex(self.tableName).whereIn(((self.idAttribute) ? self.idAttribute : "id"), self.input).then(function(output) {
return _knex(self.tableName).whereIn(((self.idAttribute) ? self.idAttribute : "id"), self.getDBObject(self.input)).then(function(output) {

while (output.length > 0) {
result.push(self.getObjectFromDBObject(output.shift()));
Expand Down

0 comments on commit 692737f

Please sign in to comment.