From 6409f4d6463e9e229ee7f53693daf0a35dcbf962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=99=E2=97=A6=20The=20Tablet=20=E2=9D=80=20GamerGirla?= =?UTF-8?q?ndCo=20=E2=97=A6=E2=9D=A7?= Date: Mon, 25 Sep 2023 19:36:04 -0400 Subject: [PATCH] feat(api): add story/author count endpoint --- server/api/totals.get.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 server/api/totals.get.ts diff --git a/server/api/totals.get.ts b/server/api/totals.get.ts new file mode 100644 index 0000000..f1b5584 --- /dev/null +++ b/server/api/totals.get.ts @@ -0,0 +1,10 @@ +import mongoose from "mongoose"; +import { Story } from "~/models/stories"; + +export default eventHandler(async (event) => { + let aa = mongoose.connection.db.collection("z_index_totAuthors"); + let totalStories = await Story.countDocuments({"chapters.hidden": false}); + let totalAuthors = await aa.countDocuments(); + + return {stories: totalStories, authors: totalAuthors} +}) \ No newline at end of file