instert fix fix

This commit is contained in:
jusax23 2023-03-29 11:11:59 +02:00
parent 20b72e9798
commit ce7012de3a
Signed by: jusax23
GPG key ID: 499E2AA870C1CD41
3 changed files with 6 additions and 3 deletions

View file

@ -143,9 +143,10 @@ export const addOTA: Act = {
},
func: async (client: Client, data: any, aws: (code: string, data: any) => void) => {
try {
await insert(signupOTA.token, signupOTA.expires, signupOTA.usesLeft)
let resp = await insert(signupOTA.token, signupOTA.expires, signupOTA.usesLeft)
.add(data.token, data.expires, data.usesLeft)
.query(db);
if(resp.affectedRows == 0) throw new Error("insertion fail");
} catch (error) {
await update(signupOTA)
.set(signupOTA.expires, data.expires)

View file

@ -384,9 +384,10 @@ export const addRoomOTA: Act = { // or change it, primary key is room and token
let roomID = await client.isRoomAdmin(data.room, ROOM_RIGHTS.OTA);
if (roomID == -1) return void aws("error", "roomAdmin");
try {
await insert(roomOTAs.roomID, roomOTAs.token, roomOTAs.name, roomOTAs.expires, roomOTAs.usesLeft)
let resp = await insert(roomOTAs.roomID, roomOTAs.token, roomOTAs.name, roomOTAs.expires, roomOTAs.usesLeft)
.add(roomID, data.token, data.name, data.expires, data.usesLeft)
.query(db);
if (resp.affectedRows == 0) throw new Error("insertion fail");
} catch (error) {
await update(roomOTAs)
.set(roomOTAs.expires, data.expires)

View file

@ -19,9 +19,10 @@ export const getSettings = async (type: string) => {
export const setSettings = async (type: string, data: string) => {
try {
await insert(settings.type, settings.data)
let resp = await insert(settings.type, settings.data)
.add(type, data)
.query(db);
if (resp.affectedRows == 0) throw new Error("insertion fail");
} catch (error) {
await update(settings)
.set(settings.data, data)