问题的解决:
设置mongoose.model()的第三个参数,代码如下。
module.exports = mongoose.model('Course', userSchema,'course');
或者,可以给Schema传入第二个参数,如下。
![复制代码](https://common.cnblogs.com/images/copycode.gif)
const userSchema = new Schema({ name: { type: String}, age: { type: Number}, sex: { type: Number}, city: { type: String}, company: { type: String} },{ collection: 'course' })标签:String,course,collections,mongoose,type,连接,Schema From: https://www.cnblogs.com/nightminer/p/16735808.html