2016-02-05 84 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

回答