this is a case where you are adding the model to the global mongoose object but opening a separate connection mongo.createConnection()
that the models are not part of. Since the model has no connection it cannot save to the db.
this is solved either by connecting to mongo on the global mongoose connection:
var connection = mongo.createConnection('mongodb://127.0.0.1/test');
// becomes
var connection = mongo.connect('mongodb://127.0.0.1/test');
or by adding your models to your separate connection:
var BookModel = mongo.model('abook', BookSchema);
// becomes
var BookModel = connection.model('abook', BookSchema);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…