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的集合.

相关文章

这篇文章主要介绍“基于nodejs的ssh2怎么实现自动化部署”的...
本文小编为大家详细介绍“nodejs怎么实现目录不存在自动创建...
这篇“如何把nodejs数据传到前端”文章的知识点大部分人都不...
本文小编为大家详细介绍“nodejs如何实现定时删除文件”,内...
这篇文章主要讲解了“nodejs安装模块卡住不动怎么解决”,文...
今天小编给大家分享一下如何检测nodejs有没有安装成功的相关...