我正在尝试将对象导入猫鼬模式,但出现“意外标识符”错误。我是否在犯语法错误,我不确定如何导出。
我的导出对象
const electronic = {
title: { type: String },
description: { type: String },
price: { type: String },
location: { type: String },
image: { type: Array },
phone: {
type: String
},
email: {
type: String
},
author: {
type: String,
ref: 'User'
}
}
export default electronic
我在其中导入对象的地方
const mongoose = require('mongoose');
import electronic from '../master_objects/electronics'
const electronics = new mongoose.Schema(
electronic, {
timestamps: true
});
module.exports = mongoose.model('vancouver_electronic', electronics);
答案 0 :(得分:1)
做事export default electronic
,做module.exports=electronic
了解更多信息Getting Unexpected Token Export