rtags
rtags is a tag management system for node.js, backed by Redis. This module could be used to storage tags of blogs, commodities, photographs, individuals in the social web, etc.
Installation
$ npm install rtags
Example
The first thing you'll want to do is create a Tag
instance, which allows you to pass a key
, used for namespacing within Redis so that you may have several tags in the same db.
var tag = rtags.createTag('blogs');
rtags acts against string separated with ','. The following example uses an array for our "database", containing some strings, which we add to rtags by calling Tag#add()
padding the body of text and an id of some kind, in this case the index.
var strs = ;strs;strs;strs;strs;strs; strs;
To perform a query on an id, simply invoke Tag#queryID()
with a string and pass a callback, which receives an array of ids when present, or an empty array otherwise.
tag ;
The previous example would yield the following output:
Tags for "3":
- linux kernel linus 1991
To perform a query on two objects to find out the tags they both have, also invoke Tag#queryID()
, but with two strings and a callback.
tag ;
The previous example would yield the following output:
Tags for "3" and "4" both have:
- kernel linux
To perform a query on tags, simply invoke Tag#queryTag()
, with tags separated with ',' and a callback.
tag ;
The previous example would yield the following output:
The objects own the "music,food" tags:
- 0 1
API
rtagsTag#Tag#Tag#Tag#Tag#Tag#
Examples:
var tag = rtags;tag;tag;tag;tag;tag;tag;tag;
Extras
Running examples:
$ git clone git@github.com:bangerlee/Rtags.git$ cd Rtags/test$ node index.js
License (MIT)
Copyright (c) 2012, LiXin, bangerlee@gmail.com.