我已经尝试了不同的解决方案,但无法解决这个问题。
这是我的代码
var mongoose = require('mongoose');
var schema = new mongoose.Schema({
name:{
type:String,
required:true
},
email:{
type:String,
required:true,
lowercase:true
}
});
mongoose.connect('mongodb://localhost:27017/test');
//parameters are model name,schema,collection name
var Emp = mongoose.model('Emp','schema','users');
字符串
1条答案
按热度按时间jobtbby31#
您正在model方法的第二个参数中使用字符串,并且它需要Schema。
这解决了你的问题:
字符串
以下是您必须使用的参数类型:用途:
型
更多信息请访问:http://mongoosejs.com/docs/api.html#index_Mongoose-model