diff --git a/backend/data.ts b/backend/data.ts index 27a8b0a..f3998db 100644 --- a/backend/data.ts +++ b/backend/data.ts @@ -132,8 +132,8 @@ export const put = (sector: DataSector, key: NID, data: AssFile | AssUser): Prom } else { // ? SQL - // todo: check existing - await MySql.put('assfiles', key, data); + if (!(await MySql.get('assfiles', key))) await MySql.put('assfiles', key, data); + else return reject(new Error(`File key ${key} already exists`)) // todo: modify users SQL files property } @@ -156,8 +156,8 @@ export const put = (sector: DataSector, key: NID, data: AssFile | AssUser): Prom } else { // ? SQL - // todo: check existing - await MySql.put('assusers', key, data); + if (!(await MySql.get('assusers', key))) await MySql.put('assusers', key, data); + else return reject(new Error(`User key ${key} already exists`)); } }