diff --git a/README.md b/README.md index c426a61..1447889 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/mysql.js b/lib/mysql.js index b43ef40..90eb712 100644 --- a/lib/mysql.js +++ b/lib/mysql.js @@ -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; }