feat: added existing check for SQL data put

pull/243/head
Josh Moore 1 year ago
parent 310a2bb117
commit c0cf6598e3

@ -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`));
}
}

Loading…
Cancel
Save