Polarcraft/web/server/api/store/index.delete.js
Xeovalyte 8121b9b975
Some checks failed
Build and Deploy / Deploy Web (push) Has been cancelled
Build and Deploy / Deploy Discord Bot (push) Has been cancelled
Lots of improvements and changes
2023-05-27 12:02:33 +02:00

18 lines
464 B
JavaScript

import { ObjectId } from "mongodb";
export default defineEventHandler(async (event) => {
const { id } = await readBody(event)
const user = await getAuth(event)
const storesColl = db.collection('stores');
const result = await storesColl.deleteOne({ _id: new ObjectId(id) })
if (result.deletedCount === 1) {
return result
} else {
throw createError({ statusCode: 500, statusMessage: 'Error tijdens het verwijderen van de store' })
}
});