微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

node.js – Mongoose收集什么东西?

我想通过Mongoose浏览存储在Mongodb中的原始数据.它去哪儿了?我有一个名为Profile的Schema,其中存储了几个配置文件,但是使用Mongodb shell db.Profiles.find()和db.Profile.find()不会返回任何内容.

架构,

var Profile = new Schema({
    username      : {type: String,index: true,required: true},password      : {type: String,name          : {type: String,required: true}
});

解决方法

使用Mongoose时的认集合名称是较低的,多元化的模型名称.

因此,如果您要为ProfileSchema创建模型,请执行以下操作:

var ProfileModel = mongoose.model('Profile',ProfileSchema);

集合名称配置文件;所以你会在shell中找到它的内容为db.profiles.find().

请注意,如果您不喜欢认行为,则可以将自己的集合名称作为mongoose.model的第三个参数提供:

var ProfileModel = mongoose.model('Profile',ProfileSchema,'MyProfiles');

将目标定位名为MyProfiles的集合.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐