Skip to content

Commit

Permalink
docs about router
Browse files Browse the repository at this point in the history
  • Loading branch information
guileen committed Apr 30, 2011
1 parent 7d66bb1 commit fb232c3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Readme.md
Expand Up @@ -5,6 +5,7 @@
* [Quick Start](#quickstart)
* [Connect easier](#quickstart-1)
* [Server options and BSON options](#quickstart-2)
* [Router](#router)
* [Similar API with node-mongodb-native](#quickstart-3)
* [Cursor easier](#quickstart-4)
* [MVC helper](#quickstart-5)
Expand Down Expand Up @@ -93,6 +94,22 @@ And native_parser options will automatically set from wheather native_parser ava
var mongo = require('mongoskin'),
db = mongo.db('localhost:27017/test?auto_reconnect');

<a name='router'></a>

var db = mongo.router(function(coll_name){
switch(coll_name) {
case 'user':
case 'message':
return mongo.db('192.168.1.3/auth_db');
default:
return mongo.db('192.168.1.2/app_db');
}
});
db.bind('user', require('./shared-user-methods'));
var users = db.user; //auth_db.user
var messages = db.collection('message'); // auth_db.message
var products = db.collection('product'); //app_db.product

<a name='quickstart-3'></a>

Similar API with node-mongodb-native
Expand Down Expand Up @@ -201,6 +218,10 @@ Create [SkinServer](#skinserver) of native [ServerCluster](https://github.com/ch

Create [SkinServer](#skinserver) of native [ServerPair](https://github.com/christkv/node-mongodb-native/blob/master/lib/mongodb/connection.js#L190)

### router(select)

select is function(collectionName) returns a database instance, means router collectionName to that database.

[Back to index](#index)

<a name='skinserver'>
Expand Down

0 comments on commit fb232c3

Please sign in to comment.