next/server/api/totals.get.ts

10 lines
380 B
TypeScript

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}
})