I've installed MongoDB v3.0.6 on my Windows 7 machine and I'm trying to start the database.
I have one command line window with the node app running and second command line window in which I navigated to 'D:/mongodb/bin' and used:
mongodb.exe --dbpath d:/mongodb/data
Which listens for connections, so I opened a third command line window and tried this:
mongodb.exe
Which gives me: I CONTROL Hotfix KB2731284 or later update is not installed, will zero out data files MongoDB shell version 3.0.6 connecting to: test
Then when I run the app in the browser it crashes and I get a red 'app crashed - blah blah blah' in the command line window that's running the node app.
I have this in my app.js file:
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/emedb');
var Schema = mongoose.Schema;
// create a schema
var userSchema = new Schema({
name: String,
username: {
type: String,
required: true,
unique: true
},
password: {
type: String,
required: true
},
admin: Boolean,
location: String,
meta: {
age: Number,
locale: String
},
created_at: Date,
updated_at: Date
});
// on every save, add the date
userSchema.pre('save', function(next) {
// get the current date
var currentDate = new Date();
// change the updated_at field to current date
this.updated_at = currentDate;
// if created_at doesn't exist, add to that field
if (!this.created_at)
this.created_at = currentDate;
next();
});
// the schema is useless so far
// we need to create a model using it
var User = mongoose.model('User', userSchema);
// make this available to our users in our Node applications
module.exports = User;
Which I suspect is where my problem is. As many could probably guess I'm very new to this. It's my first attempt at using MongoDB. What's wrong?