Q: Not able to find mongoose models after creation I have created one express app and the database connection .


var app = express();
app.db = mongoose.connect("mongodb://localhost/forcast-db");

var accountSchema = new mongoose.Schema({
            accountId:{
                type:String,
                required:true
            }
        });
app.db.model('Account', accountSchema);
console.log(app.db.models);


But it is printing a empty object.
used library
"express": "^4.13.4",
"mongoose": "^4.4.7",
Any kind of help will be highly appreciated.

A: to get  all models created with your mongoose connection  use app.db.connection.models so your code should be like this:
    var app = express();
    app.db = mongoose.connect("mongodb://localhost/forcast-db");

    var accountSchema = new mongoose.Schema({
                accountId:{
                    type:String,
                    required:true
                }
            });
   var accountModel= app.db.model('Account', accountSchema);
    console.log(app.db.connection.models);
   //to create a document from this Account model and save it
    var newAccount= new accountModel({accountId:'1111'});
    newAccount.save();


A: For list of models use console.log(mongoose.models); instead of console.log(app.db.models);. console.log(app.db.models); will not give you list of model created.
Durga
