//Preferred (shorthand) exports.Rectangle = schemaClass; module.exports = schemaClass;
const mongoose = require("mongoose"); const rectangleSchema = mongoose.Schema({ width: { type: Number, required: [true, 'Width is required'] }, height: { type: Number, required: [true, 'Height is required'] } }); const schemaClass = mongoose.model('rectangles', rectangleSchema); //Exporting exports.Rectangle = schemaClass;
const {Rectangle} = require('./foo');
//Exporting //exports.Rectangle = schemaClass; module.exports = schemaClass;
const Rectangle = require('./foo');