Mongoose Adapter Single Index support

This commit is contained in:
Nashad Alam 2012-09-20 14:13:07 +10:00
parent 4ce4a0bc2c
commit 768ba2c677
1 changed files with 6 additions and 2 deletions

View File

@ -48,8 +48,12 @@ function MongooseAdapter(client) {
MongooseAdapter.prototype.define = function (descr) { MongooseAdapter.prototype.define = function (descr) {
var props = {}; var props = {};
Object.keys(descr.properties).forEach(function (key) { Object.keys(descr.properties).forEach(function (key) {
props[key] = descr.properties[key].type; props[key] = {};
if (props[key].name === 'Text' || props[key].name === 'JSON') props[key] = String; props[key].type = descr.properties[key].type;
if (props[key].type.name === 'Text' || props[key].type.name === 'JSON') props[key].type = String;
if (descr.properties[key].index) {
props[key].index = descr.properties[key].index;
}
}); });
var schema = new mongoose.Schema(props); var schema = new mongoose.Schema(props);
this._models[descr.model.modelName] = mongoose.model(descr.model.modelName, schema); this._models[descr.model.modelName] = mongoose.model(descr.model.modelName, schema);