In my models/user.js file:
var mongoose = require(\'mongoose\');
var Schema = mongoose.Schema;
var userSchema = new Schema({
(define schema
In using express, one of the common mistake is by requiring the express before mongoose. This results to "MissingSchemaError: Schema hasn't been registered for model "User"." error.
You can easily fix it by correcting the "require" order (i.e mongoose then express)
var mongoose = require('./config/mongoose'),
express = require('./config/express');