Commit 6549ba7e authored by kusang96's avatar kusang96
Browse files

dd

parent 7cb7c566
import express from "express"; import express from "express";
import path from 'path';
import multer from 'multer';
import productCtrl from '../controllers/product.controller.js'; import productCtrl from '../controllers/product.controller.js';
// process.cwd() + '/client/public/image'
const router = express.Router() const router = express.Router()
const upload = multer({
storage: multer.diskStorage({
destination(req, file, cb) {
cb(null, 'uploads/');
}, // 저장 경로 변경
filename(req, file, cb) {
cb(null, new Date().valueOf() + path.extname(file.originalname));
}, // 파일명 변경
}),
});
router.route('/regist') router.route('/regist')
.post(productCtrl.regist) .post(productCtrl.imageUpload, productCtrl.regist)
// upload.array('main_image'),
export default router export default router
\ No newline at end of file
import mongoose from 'mongoose' import mongoose, { mongo } from 'mongoose'
const { String, Number, Array } = mongoose.Schema.Types const { String, Number } = mongoose.Schema.Types
const productschema = new mongoose.Schema ({
pro_name: {
type: String,
required: true
}
})
const ProductSchema = new mongoose.Schema({ const ProductSchema = new mongoose.Schema({
pro_name: { pro_name: {
...@@ -25,20 +32,19 @@ const ProductSchema = new mongoose.Schema({ ...@@ -25,20 +32,19 @@ const ProductSchema = new mongoose.Schema({
required: true, required: true,
}, },
sub_category: { sub_category: {
type: Array, type: [String],
required: true, required: true,
}, },
description: { description: {
type: String, type: String,
required: true, required: true,
}, },
main_image: { main_imgUrl: {
type: String, type: String,
required: true, required: true
}, },
detail_image: { detail_imgUrls: {
type: String, type: [String]
required: true,
} }
}, { }, {
timestamps: true timestamps: true
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment