A
A
Abc Edc2015-01-26 19:32:26
Node.js
Abc Edc, 2015-01-26 19:32:26

What is the correct way to declare exports so that each time it is not written in js?

there is code in model.js

exports.findAll = function(req,res) {        
}
exports.findById = function(req,res) {
  }

and there will be all the crud
how to do something like
exports
.findById
.findAll

If route.js is affected, then here is its code
app.get('/tester', require('../controllers/tester').findAll);
app.get('/tester/:id', require('../controllers/tester').findById);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Puzynya, 2015-01-26
@gleber1

Mmm... Maybe you are looking for

module.exports = {
  findById: function() {},
  findAll: function() {}
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question