Reputation: 155
I'm using this model from https://www.codementor.io/olatundegaruba/nodejs-restful-apis-in-10-minutes-q0sgsfhbd :
'use strict';
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var TaskSchema = new Schema({
name: {
type: String,
required: 'Kindly enter the name of the task'
},
Created_date: {
type: Date,
default: Date.now
},
status: {
type: [{
type: String,
enum: ['pending', 'ongoing', 'completed']
}],
default: ['pending']
}
});
module.exports = mongoose.model('Tasks', TaskSchema);
On the last step 'putting everything together', it says i have to load the created model above. When I run the HTTP commands there has been no response to the server, and when I checked, there is no collection inside my database. How do I do that?
Upvotes: 0
Views: 404
Reputation: 1570
That required
in name
has to be boolean or a function. You can use either:
required: true
or
required: [true, "Kindly enter the name of the task"]
Also you should check console to find out the exact problem which cause your application stopped.
Upvotes: 2