I am writing code with node.js. Quite new to this and the problem is that mongoose returns an empty array. There must be a mistake somewhere in this code, but I cannot find it. Any ideas?
Dresses schema
var dressesSchema = mongoose.Schema({
title:{
type: String,
required: true
},
description:{
type: String,
required: true
}
});
var Dress = module.exports = mongoose.model('Dress', dressesSchema);
Get dresses from database
module.exports.getDresses = function(callback, limit){
Dress.find(callback).limit(limit);
};
Dress = require('./models/dress');
app.get('/api/dresses', function(req, res){
Dress.getDresses(function(err, dresses){
if(err){
throw err;
}
res.json(dresses);
});
});