From 768ba2c677606403a948418f5b560fd694367c14 Mon Sep 17 00:00:00 2001 From: Nashad Alam Date: Thu, 20 Sep 2012 14:13:07 +1000 Subject: [PATCH 1/2] Mongoose Adapter Single Index support --- lib/adapters/mongoose.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/adapters/mongoose.js b/lib/adapters/mongoose.js index c541a621..acd2c1e1 100644 --- a/lib/adapters/mongoose.js +++ b/lib/adapters/mongoose.js @@ -48,8 +48,12 @@ function MongooseAdapter(client) { MongooseAdapter.prototype.define = function (descr) { var props = {}; Object.keys(descr.properties).forEach(function (key) { - props[key] = descr.properties[key].type; - if (props[key].name === 'Text' || props[key].name === 'JSON') props[key] = String; + props[key] = {}; + 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); this._models[descr.model.modelName] = mongoose.model(descr.model.modelName, schema); From 45e1df09db9dcb4b4ae592bc18ab76f381c84e00 Mon Sep 17 00:00:00 2001 From: Nashad Alam Date: Thu, 20 Sep 2012 14:22:36 +1000 Subject: [PATCH 2/2] Mongoose Adapter Single Index support-Spacing Fix --- lib/adapters/mongoose.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/adapters/mongoose.js b/lib/adapters/mongoose.js index acd2c1e1..8b1def20 100644 --- a/lib/adapters/mongoose.js +++ b/lib/adapters/mongoose.js @@ -48,7 +48,7 @@ function MongooseAdapter(client) { MongooseAdapter.prototype.define = function (descr) { var props = {}; Object.keys(descr.properties).forEach(function (key) { - props[key] = {}; + props[key] = {}; 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) {