I am new to node.js and I have the following exported function
LiveEvent.js
function liveEvent(connection) {
this.db = connection.
}
liveEvent.prototype.someMethod = function() { }
module.exports = liveEvent;
Now in another file
Enduser.js
var LiveEvent = require('./LiveEvent');
When i try to do the following i get TypeError: object is not a function
var liveEvent = new LiveEvent(connection);
What am i doing wrong ? Any suggestions appreciated.
You don't need the function keyword to create a prototype method.
function liveEvent(connection) {
this.db = connection;
}
liveEvent.prototype.someMethod = function() { }
module.exports = liveEvent;