Commit ae9446cf authored by 이재연's avatar 이재연
Browse files

Merge remote-tracking branch 'origin/jiwon' into jaeyeon

parents d3301a50 78f4f056
...@@ -2,11 +2,22 @@ import express from "express"; ...@@ -2,11 +2,22 @@ import express from "express";
import path from 'path'; import path from 'path';
import multer from 'multer'; import multer from 'multer';
import productCtrl from '../controllers/product.controller.js'; import productCtrl from '../controllers/product.controller.js';
import fs from 'fs'
// process.cwd() + '/client/public/image' // process.cwd() + '/client/public/image'
const router = express.Router() const router = express.Router()
fs.readdir('uploads', (error, data) => {
if (error) {
fs.mkdirSync('uploads');
if (data == undefined) {
fs.mkdirSync('/main')
fs.mkdirSync('/detail')
}
} else console.log("else data",data)
})
const upload = multer({ const upload = multer({
storage: multer.diskStorage({ storage: multer.diskStorage({
destination(req, file, cb) { destination(req, file, cb) {
......
import mongoose from 'mongoose'
const { String, Number, Array, ObjectId } = mongoose.Schema.Types
const productschema = new mongoose.Schema ({
pro_name: {
type: String,
required: true
},
price:{
type: Number,
required: true
},
main_image: {
type: String,
required: true
},
color:{
type: String,
required: true
},
size:{
type: String,
required: true
},
productObjectId: {
type: ObjectId,
required: true
}
})
const CartSchema = new mongoose.Schema({
userId: {
type: String,
// required: true
},
products : {
type: [productschema],
required: true
}
}, {
timestamps: true
})
export default mongoose.models.Cart || mongoose.model('Cart', CartSchema)
\ No newline at end of file
...@@ -20,6 +20,14 @@ const ProductSchema = new mongoose.Schema({ ...@@ -20,6 +20,14 @@ const ProductSchema = new mongoose.Schema({
required: true, required: true,
default: 0 default: 0
}, },
size: {
type: Array,
required: true
},
color: {
type: Array,
required: true
},
main_category: { main_category: {
type: String, type: String,
required: true, required: 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