【问题标题】:getting error trying to import object into mongoose schema尝试将对象导入猫鼬模式时出错
【发布时间】:2020-06-24 23:57:41
【问题描述】:

我正在尝试将对象导入猫鼬模式,但出现“意外标识符”错误。我是否犯了语法错误,我不确定如何导出。

我的导出对象


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);

【问题讨论】:

    标签: javascript node.js reactjs mongodb mongoose


    【解决方案1】:

    不做export default electronic,做module.exports=electronic 欲了解更多信息Getting Unexpected Token Export

    【讨论】:

      猜你喜欢
      • 2015-08-21
      • 2015-11-08
      • 2018-01-05
      • 1970-01-01
      • 2021-04-10
      • 2019-10-18
      • 1970-01-01
      • 1970-01-01
      • 2019-10-30
      相关资源
      最近更新 更多