Merge branch 'master' of github.com:1602/jugglingdb-mysql

This commit is contained in:
Anatoliy Chakkaev 2013-01-30 22:17:12 +07:00
commit 035a8e8bac
2 changed files with 18 additions and 3 deletions

View File

@ -1,6 +1,6 @@
## JugglingDB-MySQL [![Build Status](https://travis-ci.org/1602/jugglingdb-mysql.png)](https://travis-ci.org/1602/jugglingdb-mysql)
PostgreSQL adapter for JugglingDB.
MySQL adapter for JugglingDB.
## Usage

View File

@ -23,6 +23,7 @@ exports.initialize = function initializeSchema(schema, callback) {
schema.adapter = new MySQL(schema.client);
schema.adapter.schema = schema;
// schema.client.query('SET TIME_ZONE = "+04:00"', callback);
schema.client.query('USE `' + s.database + '`', function (err) {
if (err && err.message.match(/^unknown database/i)) {
@ -36,6 +37,11 @@ exports.initialize = function initializeSchema(schema, callback) {
});
} else callback();
});
// MySQL specific column types
schema.types = {
Point: function Point() {}
};
};
/**
@ -228,9 +234,15 @@ MySQL.prototype.all = function all(model, filter, callback) {
if (err) {
return callback(err, []);
}
callback(null, data.map(function (obj) {
var objs = data.map(function (obj) {
return self.fromDatabase(model, obj);
}));
});
if (filter && filter.include) {
this._models[model].model.include(objs, filter.include, callback);
} else {
callback(null, objs);
}
}.bind(this));
return sql;
@ -533,6 +545,9 @@ function datatype(p) {
case 'Boolean':
dt = 'TINYINT(1)';
break;
case 'Point':
dt = 'POINT';
break;
}
return dt;
}