【发布时间】:2016-02-05 03:10:14
【问题描述】:
我已经在我的 Windows 7 机器上安装了MongoDB v3.0.6,我正在尝试启动数据库。
我有一个运行节点应用程序的命令行窗口和第二个命令行窗口,我在其中导航到“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.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。怎么了?
【问题讨论】:
-
For the hotfix。 blah blah blah 部分是错误中有趣的部分,应该可以准确地告诉您发生了什么。
-
尝试在没有 b 的情况下运行 mongod.exe。
-
我认为它有效。如果您 - @Moshe Karmel - 想将您的评论作为答案,我会在下周再次检查它,如果它仍然有效,则将其设置为正确答案。
-
我想知道是否有人想知道废话、废话、废话部分。 @ShanShan 它是“在开始之前等待文件更改”