routes.js 443 B

1234567891011121314151617181920
  1. var model = require('./modelA');
  2. exports.home = function(req, res, next) {
  3. model.find(function(err, docs) {
  4. if (err) return next(err);
  5. res.send(docs);
  6. });
  7. };
  8. exports.modelName = function(req, res) {
  9. res.send('my model name is ' + model.modelName);
  10. };
  11. exports.insert = function(req, res, next) {
  12. model.create({name: 'inserting ' + Date.now()}, function(err, doc) {
  13. if (err) return next(err);
  14. res.send(doc);
  15. });
  16. };