I could not find anyway to define 2 set of models and use them in the connection I want..
How may I do?
thanks
解决方案
Create two connections and add different models to each one:
var mongoose = require('mongoose');
var db1 = mongoose.createConnection('localhost', 'test');
var Cat = db1.model('Cat', new mongoose.Schema({ name: String }));
var db2 = mongoose.createConnection('localhost', 'test');
var Dog = db2.model('Dog', new mongoose.Schema({ name: String }));
In this example, the 'Cat' model is tied to connection db1 and the Dog model is tied to db2.