1.0.1 • Published 9 years ago
baucis-decorator-insensitive v1.0.1
baucis-decorator-insensitive
Allows an insensitive
query parameter and acts like a very basic auto-complete.
Install
npm install baucis-decorators baucis-decorator-insensitive --save
Usage
Just add the decorator and then suppose you have some users named "John", "joe", and "JONNY". You'd be able to GET all three of those users via /api/users?insensitive[name]=jo
.
Example
controllers/Resource.js
var baucis = require('baucis');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var ObjectId = Schema.Types.ObjectId;
var ResourceProps = {};
ResourceProps.name = {
type: String
};
var ResourceSchema = new Schema(ResourceProps);
var ResourceModel = mongoose.model('Resource', ResourceSchema);
var ResourceController = baucis.rest('Resource');
var decorators = require('baucis-decorators');
decorators.add.call(ResourceController, [
'baucis-decorator-insensitive'
]);
/**
* Expose controller.
*/
module.exports = ResourceController;