const mongoose = require('mongoose');
const schema = mongoose.schema;
const marioCharSchema = new schema({
name: String,
weight: Number
});
const marioChar = mongoose.model('marioChar', marioCharSchema);
module.exports = marioChar;
答案 0 :(得分:1)
二线使用 const schema = mongoose.Schema; javascript是一种区分大小写的语言。
答案 1 :(得分:0)
只需将对象导出为对象,并将测试要求作为对象。像这样:
module.exports = {MarioChar};
const assert = require('assert');
const {MarioChar} = require('../models/mariochar');
答案 2 :(得分:0)
const Schema = mongoose.Schema;
错了。