anastasiaalt / finalProject

0 stars 0 forks source link

Mongoose Model Data rendering issue #1

Closed anastasiaalt closed 8 years ago

anastasiaalt commented 8 years ago

I have a route for posts and a model set up with a schema for posts. I also created a collection in my database from the command line with a piece of post data in it. When I got to the route, I get a blank page that just says [ ]

https://github.com/anastasiaalt/finalProject/blob/master/app.js https://github.com/anastasiaalt/finalProject/tree/master/models

app.get('/posts', function(req, res){
  mongoose.model('posts').find(function(err, posts) {
    res.send(posts);
  });
});

I tried creating new collections in the command line, creating collections/models totally through the model files, etc. Nothing is working

phlco commented 8 years ago

Update your code to use the Post model .

Post.find({}, function(err, posts){
  res.send(posts);
});