arnaucube
arnaucube/thoughtsPublic Self-hosted repository
thoughts/node_modules/mongoose/examples/express/connection-sharing/routes.js
node_modules/mongoose/examples/express/connection-sharing/routes.jsRaw
 1
 2var model = require('./modelA');
 3
 4exports.home = function(req, res, next) {
 5  model.find(function(err, docs) {
 6    if (err) return next(err);
 7    res.send(docs);
 8  });
 9};
10
11exports.modelName = function(req, res) {
12  res.send('my model name is ' + model.modelName);
13};
14
15exports.insert = function(req, res, next) {
16  model.create({name: 'inserting ' + Date.now()}, function(err, doc) {
17    if (err) return next(err);
18    res.send(doc);
19  });
20};