cant get data from database after multiple schema declared (mongoose + express + mongodb
When exporting multiple models from a single file like you are in schema.js, you need to give each exported model its own exports
field name.
For example, replace the multiple module.exports = ...
lines in schema.js with this code at the end of the file that exports all models:
module.exports = { User: User, Question: Question, Answer: Answer, Module: Module, Role: Role};
And then in index.js you can access the models like so:
var models = require('./schema');...models.User.findOne(...