I have following in server.js :
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
and a model like this one which works fine ! :
var userSchema = new Schema({
firstName: { type: String, trim: true, required: true },
lastName: {type: String, trim: true, required: true},
cellPhoneNumber : {type: Number, unique: true},
email: { type: String, unique: true, lowercase: true, trim: true },
password: String
});
and there's an another model like below one which doesn't work !
var jobSchema = new Schema({
category: {type: Number, required: true},
title: {type: String, required: true},
tags: [String],
longDesc: String,
startedDate: Date,
views: Number,
report: Boolean,
reportCounter: Number,
status: String,
poster: String,
lastModifiedInDate: Date,
verified: Boolean
});
the two var are as follow :
var User = mongoose.model('User', userSchema);
var Job = mongoose.model('Job', jobSchema);
-- mongod doesn't log any error after server.js is connected to it . Does anybody know what's wrong with my second model ?
Mongoose won't create the jobs
collection for the model until the first document of that model is saved.
Job.create({category: 1, title: 'Minion"}, function(err, doc) {
// At this point the jobs collection is created.
});