0

I've done two collections before "article" and "news" and it all works... If i want to do other collection mongo cant find it

var mongoose = require('mongoose');

var calendarSchema = mongoose.Schema({
name:{
    type: String,
    required: true
},
create_date:{
    type: Date,
    default: Date.now
}
});

var Calendar = module.exports = mongoose.model('calendar',calendarSchema);

module.exports.getCalendar = function(callback, limit){
Calendar.find(callback).limit(limit);

}
});

Calendar.find() returns empty array. if i change mongoose.model to " news" it works

Stephan
  • 61
  • 1
  • 1
  • 4
  • Mongoose is expecting `"calendars"` as the name of the collection. Perhaps it's called `"calendar"` in your database? If so use the third argument on the model definition `mongoose.model('calendar', calendarSchema, 'calendar')` which specifies a specific collection name rather than the pluralized default. – Neil Lunn Nov 17 '17 at 11:18

1 Answers1

0

You can also check with commands if you don't have robomongo,

 >mongo
//Mongodb
    >show dbs  
//It shows the database
    >use yourdbname 
//type your db name
    >show collections 
//It shows all collections what you have done so far
krbalaji
  • 454
  • 4
  • 12