I\'m new to node.js. i have two files. they are index.js and db.js
my index.js is
var connection =
if you want something from the db module to be accessible in other modules, you need to expose it, by using module.exports
add to the end of your db.js file:
module.exports = {
appModel : appModel,
Device : Device
};
and then in your index.js you can do:
device = new connection.Device({
id: 93,
name: 'test1'
});
you can read more about it here
node.js treats every file as a module. so to include any source file into another you need to export it at the source end and import it using require at the importing file.