var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/rose');

var featureSchema = new mongoose.Schema({
  name: String,
  examples: [{
    technology: String,
    snippets: [String]
  }]
});

featureSchema.statics.search = function (query, callback) {
   this.find({ examples: { $elemMatch: { snippets: new RegExp(query, 'i') }}})
       .lean()
       .select('-__v -_id -examples._id')
       .exec(function (err, docs) {
         callback(docs);
       });
};

module.exports = mongoose.model('Feature', featureSchema);

@@ -1,83 +1,230 @@
 var 
-mongoose = require('mongoose');%0Amongoose.connect('mongodb://localhost/rose'
+debug = require('debug')('rose');%0Avar mongoose = require('mongoose');%0A%0Avar mongoURI = process.env.MONGOLAB_URI %7C%7C 'mongodb://localhost/mydb';%0Adebug('Connecting to MongoDB at ' + mongoURI + '...');%0Amongoose.connect(mongoURI
 );%0A%0A

Connect to MongoLab if MONGOLAB_URI is set