delete room when empty
This commit is contained in:
@@ -12,8 +12,10 @@ export async function getRoomOwner(roomId: number) {
|
||||
return await execQueryAsync(query, values);
|
||||
}
|
||||
|
||||
/**
|
||||
* get all the data needed to reply to a message in a room
|
||||
*/
|
||||
export async function getLastMsgData(roomId: number) {
|
||||
|
||||
const query = `
|
||||
SELECT
|
||||
msg.message_id AS id,
|
||||
@@ -59,3 +61,21 @@ export async function getLastMsgData(roomId: number) {
|
||||
const values = [roomId];
|
||||
return await execQueryAsync(query, values);
|
||||
}
|
||||
|
||||
export async function getRoomOnMessageId(messageId: number) {
|
||||
const query = `SELECT room_id FROM app_room_message WHERE message_id = ?`;
|
||||
const values = [messageId];
|
||||
return await execQueryAsync(query, values);
|
||||
}
|
||||
|
||||
export async function getRoomNbMessage(roomId: number) {
|
||||
const query = `SELECT COUNT(room_id) AS nbMessage FROM app_room_message WHERE room_id = ?`;
|
||||
const values = [roomId];
|
||||
return await execQueryAsync(query, values);
|
||||
}
|
||||
|
||||
export async function deleteRoom(roomId: number) {
|
||||
const query = `DELETE FROM app_room WHERE room_id = ?`;
|
||||
const values = [roomId];
|
||||
return await execQueryAsync(query, values);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user