For this controller I am simply trying to return all the results of a collection. There is one item in the prop collection but for some reason I keep getting an undefined error.
TypeError: Cannot call method 'find' of undefined
This is my server.js file:
'use strict';
/**
* Module dependencies.
*/
var mongoose = require('mongoose'),
passport = require('passport'),
logger = require('mean-logger');
/**
* Main application entry file.
* Please note that the order of loading is important.
*/
// Initializing system variables
var config = require('./server/config/config');
var db = mongoose.connect(config.db);
// Bootstrap Models, Dependencies, Routes and the app as an express app
var app = require('./server/config/system/bootstrap')(passport, db);
// Return all results.
app.get('/all', function(req, res) {
var d = db.prop.find();
res.json(d);
});
// Start the app by listening on <port>, optional hostname
app.listen(config.port, config.hostname);
// Initializing logger
logger.init(app, passport, mongoose);
// Expose app
exports = module.exports = app;
User.find({})
to get all values - actually...maybe what u are doing is ok - but u might needdb.prop.find({});
– ewizard Jun 17 '14 at 23:21find
on your correct Mongoose model; so something likeProp.find()
. – JohnnyHK Jun 18 '14 at 0:00