diff --git a/middlewares/validatePostForm.js b/middlewares/validatePostForm.js index 2a9cad3..a9ec6fd 100644 --- a/middlewares/validatePostForm.js +++ b/middlewares/validatePostForm.js @@ -10,7 +10,7 @@ const validatePostForm = async form => { const { brand, menu, size, shot, caffeine, photo } = await form[1]; const nums = checkInt(shot, caffeine); const validStrings = trimmer([brand, menu, size, photo]); - const length = Object.keys(form[1]).length === 8; + const length = Object.keys(form[1]).length > 8; return nums && validStrings && length; }; diff --git a/models/posts-db.js b/models/posts-db.js index ab187c8..c0bd19b 100644 --- a/models/posts-db.js +++ b/models/posts-db.js @@ -19,8 +19,18 @@ exports.getPostDetail = async postReq => { }; exports.registerPost = async postReq => { - const { brand, menu, post_title, size, shot, caffeine, photo, postId } = - await postReq[1]; + const { + brand, + menu, + post_title, + size, + shot, + caffeine, + photo, + postId, + intensity, + description + } = await postReq[1]; const params = [ postReq[0], brand, @@ -30,7 +40,9 @@ exports.registerPost = async postReq => { shot, caffeine, photo, - postId + postId, + intensity, + description ]; const result = await connectAndQuery(PostQueries.registerPost, params); const data = result[0]; diff --git a/models/posts-queries.js b/models/posts-queries.js index 9eb2b8e..5b34009 100644 --- a/models/posts-queries.js +++ b/models/posts-queries.js @@ -2,7 +2,7 @@ const query = require('./query-fns'); const queries = { getPostDetail: `SELECT - a.brand, a.menu, a.post_title,size, a.shot,caffeine, a.photo, a.created_at, b.profileUrl, b.nickname, b.sum, b.public_id AS userId + a.brand, a.menu, a.post_title,size, a.shot,caffeine, a.photo, a.created_at, a.description, a.intensity, b.profileUrl, b.nickname, b.sum, b.public_id AS userId FROM post a LEFT JOIN user b ON a.user_id = b.public_id @@ -16,7 +16,9 @@ const queries = { 'shot', 'caffeine', 'photo', - 'public_id' + 'public_id', + 'description', + 'intensity' ]), deletePost: query.buildDelete('post', ['public_id']), writeComment: query.buildInsert('comment', ['user_id', 'post_id', 'content']),