简体   繁体   中英

getting error trying to import object into mongoose schema

I am trying to import an object into a mongoose schema, but I am getting an 'unexpected identifier' error. Am I making a syntax error or not, I am not sure how to export.

my exported object


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

where I import the object

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

module.exports=electronicexport default electronic ,做module.exports=electronic了解更多信息获取意外的令牌导出

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM