Skip to content

Commit

Permalink
new Date()
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobrunia committed Nov 21, 2023
1 parent 192c3de commit d02b920
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 6 additions & 2 deletions services/sqlwrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export async function findUserInfoById(userId): Promise<mysql.RowDataPacket[]> {
}
}

export async function getCommentsByPost(postId): Promise<mysql.RowDataPacket[]> {
export async function getCommentsByPost(
postId,
): Promise<mysql.RowDataPacket[]> {
try {
const results = await conn.query<RowDataPacket[]>(
`SELECT c.*, u.avatar, u.id AS userId
Expand Down Expand Up @@ -174,9 +176,11 @@ export async function createUserInfoTable(

export async function saveMessageToDb(DATA): Promise<mysql.RowDataPacket[]> {
try {
const now = c;
const isoDate = now.toISOString();
const results = await conn.query<RowDataPacket[]>(
'INSERT INTO `messages`(`id`, `content`, `sendBy`, `chatID`, `datetime`) VALUES (NULL,?,?,?,?)',
[DATA.content, DATA.sendBy, DATA.chatId, DATA.datetime],
[DATA.content, DATA.sendBy, DATA.chatId, isoDate],
);
return results[0];
} catch (ex) {
Expand Down
1 change: 0 additions & 1 deletion socket/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export function initSocket(app) {
content,
sendBy: (socket as any).userId,
chatId: to,
datetime: new Date(),
};
// let notifData = {
// user_id_from: (socket as any).userId,
Expand Down

0 comments on commit d02b920

Please sign in to comment.