PageRenderTime 17ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/node_modules/mongoose/examples/express/connection-sharing/routes.js

https://bitbucket.org/coleman333/smartsite
JavaScript | 20 lines | 16 code | 4 blank | 0 comment | 2 complexity | ceb4ebe32e62886b25950ab34087180a MD5 | raw file
 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};