This commit is contained in:
Akis 2023-01-10 17:55:41 +02:00
parent e4333a8b4c
commit 6bcfb0b356
Signed by untrusted user: akis
GPG Key ID: 267BF5C6677944ED
1 changed files with 3 additions and 3 deletions

View File

@ -2,9 +2,6 @@ import type { Actions } from "./$types";
import Joi from "joi";
import { fail } from "@sveltejs/kit";
import { db } from "$lib/server/db";
import dayjs from "dayjs";
const collection = db.collection("announcements");
export const actions: Actions = {
add: async ({ request, locals }) => {
@ -29,6 +26,8 @@ export const actions: Actions = {
created: now
};
const collection = db.collection("announcements");
await collection.deleteMany({});
await collection.insertOne(data);
@ -42,6 +41,7 @@ export const actions: Actions = {
if (!await locals.getSession()) {
return fail(401, { deleteError: true, deleteMessage: "You must be logged in to delete an announcement." });
} else {
const collection = db.collection("announcements");
await collection.deleteMany({});