mongoose-taggable-via-redis
v0.1.6
Published
a mongoose plugin provide fast and flexible tagging ablity to datamodle via redis, supports scope tagging
Downloads
8
Maintainers
Readme
mongoose-taggable-via-redis
a mongoose plugin provide tagging ability to datamodle via redis,
Tagging in redis is super fast and flexable. This plugin use taggable-via-redis to provide a better tagging function to mongoose datamodle
This plugin also supports scope tagging
This plugin add folloowing methos to mongoose data model:
Static Methods
- DataModel.popularTags(count:Number, scope:String(optional), callback:Function)
- DataModel.findByTags(tags:[String || String[]], query:MQuery(optional), scope:String(optional), callback:Function)
- DataModel.findWithTags(conditions:MCondition, callback:Function)
Query Extension
- execWithTag -- will call exec() and inject tags to each found data model instances
Instance Methods
- instance.setTags(tags:Array, callback:Function)
Instance Properties
- instance.tags -- return an array of all tags belong to the data model instance
Init Options
- taggable -- name of taggable object
- prefix -- [optional] redis key prefix
- redisClient -- [optional] use existing redis client, when override redisPort and redisHost options
- redisPort -- [optional] custom redis port
- redisHost -- [optional] custom redis host
- getScope -- [optional] a function figure out scope from data model instance
Install
Install the module with:
npm install mongoose-taggable-via-redis
Usage
Test
npm test
License
Copyright (c) 2014 yi Licensed under the MIT license.