instert fix fix
This commit is contained in:
parent
20b72e9798
commit
ce7012de3a
3 changed files with 6 additions and 3 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue