Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

mongoose schema

const productSchema = new Schema({
    name: { type: String, required: true },
    price: { type: String, required: true },
    size: { type: String, required: true },
    image: {
        type: String, required: true, get(image) {
            // http://localhost:5000/upload/imagename.png
            return `${APP_URL}/${image}`
        }
    },
}, { timestamps: true, toJSON: { getters: true }, id: false })
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #mongoose #schema
ADD COMMENT
Topic
Name
4+3 =