我的猫鼬模式有什么问题吗?

时间:2016-10-08 16:06:53

标签: javascript node.js mongodb express mongoose

我错了3个小时,无法解决这个问题。我的文件中没有任何内容。

var mongoose = require('mongoose');
var Schema = mongoose.Schema;

var accountSchema = mongoose.Schema({
    username: String,
    salt: String,
    hash: String,
    cover: String,
    createAt: {type: Date, default: Date.now},
    subscriber_email: String
});

module.exports = mongoose.model('account', accountSchema);

我用其他架构测试过它们都工作但不是这个。我的数据如下所示

enter image description here

1 个答案:

答案 0 :(得分:0)

我认为您无法在文档中查看任何内容的原因是导出accountSchema的方式。

在导出Account时尝试将account替换为schema

试试这个:

module.exports = mongoose.model('Account', accountSchema);

其他一切看起来都不错。

我希望这会有所帮助。