Merge branch 'master' of github.com:1602/jugglingdb-mysql
This commit is contained in:
commit
035a8e8bac
|
@ -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
|
||||
|
||||
|
|
19
lib/mysql.js
19
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue