From feeab1bb3fc8a8171eeb26d8be31cbc3549ac70d Mon Sep 17 00:00:00 2001 From: jokj624 Date: Sat, 15 Jan 2022 02:30:43 +0900 Subject: [PATCH] =?UTF-8?q?[FIX]=20=EC=8B=9C=EA=B0=84=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20now()=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/db/category.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/functions/db/category.js b/functions/db/category.js index 644c8a8..7f01079 100644 --- a/functions/db/category.js +++ b/functions/db/category.js @@ -1,10 +1,5 @@ const _ = require('lodash'); const convertSnakeToCamel = require('../lib/convertSnakeToCamel'); -const dayjs = require('dayjs'); -const utc = require('dayjs/plugin/utc'); -const timezone = require('dayjs/plugin/timezone'); -dayjs.extend(utc); -dayjs.extend(timezone); const getAllCategories = async (client, userId) => { const { rows } = await client.query( @@ -36,22 +31,20 @@ const getCategoryNames = async (client, userId) => { }; const addCategory = async (client, userId, title, imageId, content_number, order_index) => { - const currentTime = dayjs().tz("Asia/Seoul").format(); const { rows } = await client.query( ` INSERT INTO category - (user_id, title, category_image_id, content_number, order_index, created_at, edited_at) + (user_id, title, category_image_id, content_number, order_index) VALUES - ($1, $2, $3, $4, $5, $6, $6) + ($1, $2, $3, $4, $5) RETURNING * `, - [userId, title, imageId, content_number, order_index, currentTime], + [userId, title, imageId, content_number, order_index], ); return convertSnakeToCamel.keysToCamel(rows[0]); }; const updateCategory = async (client, categoryId, title, imageId) => { - const currentTime = dayjs().tz("Asia/Seoul").format(); const { rows: existingRows } = await client.query( ` SELECT * FROM category c @@ -68,11 +61,11 @@ const updateCategory = async (client, categoryId, title, imageId) => { const { rows } = await client.query( ` UPDATE category c - SET title = $1, category_image_id = $2, edited_at = $4 + SET title = $1, category_image_id = $2, edited_at = now() WHERE id = $3 RETURNING * `, - [data.title, data.imageId, categoryId, currentTime], + [data.title, data.imageId, categoryId], ); return convertSnakeToCamel.keysToCamel(rows[0]); };