2016-02-05 64 views
0

我在Windows 7机器上安装了MongoDB v3.0.6,我试图启动数据库。在nodejs应用程序中启动mongodb

我有与该节点的应用程序运行并第二个命令行窗口中的一个命令行窗口中,我导航到“d:/ mongodb的/ bin中”和用于:

mongodb.exe --dbpath d:/mongodb/data 

其中用于连接侦听,所以我打开第三个命令行窗口,并尝试这样做:

mongodb.exe 

这给了我:I CONTROL Hotfix KB2731284 or later update is not installed, will zero out data files MongoDB shell version 3.0.6 connecting to: test

然后当我在浏览器中运行应用程序崩溃我在运行节点应用程序的命令行窗口中看到一个红色的'app crash - blah blah blah'。

我有这个在我的app.js文件:

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; 

我怀疑是我的问题。很多人可能会猜到我对此很陌生。这是我第一次尝试使用MongoDB。怎么了?

+0

[对于修补程序(http://stackoverflow.com/questions/30501440/mongodb-hotfix-kb2731284)。 * blah blah blah *部分是错误的有趣部分,应该告诉你到底发生了什么。 – Shanoor

+0

尝试运行没有b的mongod.exe。 –

+0

我认为它的工作。如果您 - @Moshe Karmel - 想要将您的评论作为答案,我会在下周再次检查并将其设置为正确的答案,如果它仍在工作。 – tdrsam

回答

相关问题