node.js - TypeError: Object is not a functon in nodejs -
i'm doing user authentication through nodejs. typeerror: oject not function throwing error this
user.js
// instance of mongoose , mongoose.schema var mongoose = require('mongoose'); var schema = mongoose.schema; // set mongoose model , pass using module.exports module.exports = mongoose.model('user', new schema({ name: string, password: string, admin: boolean }));
server.js
user = require('./models/user'); app.get('/setup', function (req, res) { // create sample user var nick = new user({ // in line throwing error object not function. name: 'nick cerminara', password: 'password', admin: true }); // save sample user nick.save(function (err) { if (err) throw err; console.log('user saved successfully'); res.json({ success: true }); }); });
Comments
Post a Comment