我想通过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的集合.