【问题标题】:Is there anything wrong with my mongoose schema我的猫鼬模式有什么问题吗
【发布时间】:2017-02-17 11:18:42
【问题描述】:

我已经错了 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);

我用其他模式进行了测试,它们都可以工作,但不是这个。我的数据如下所示

【问题讨论】:

标签: javascript node.js mongodb express mongoose


【解决方案1】:

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

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

试试这个:

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

其他一切看起来都很好。

我希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 2019-11-24
    • 2012-08-04
    • 1970-01-01
    • 2021-04-10
    • 2017-07-07
    • 2019-08-12
    • 1970-01-01
    • 2018-02-15
    • 2018-03-04
    相关资源
    最近更新 更多