我错了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);
我用其他架构测试过它们都工作但不是这个。我的数据如下所示
答案 0 :(得分:0)
我认为您无法在文档中查看任何内容的原因是导出accountSchema
的方式。
在导出Account
时尝试将account
替换为schema
。
试试这个:
module.exports = mongoose.model('Account', accountSchema);
其他一切看起来都不错。
我希望这会有所帮助。