next/server/api/story/[id]/lovers.get.ts

14 lines
309 B
TypeScript
Raw Normal View History

import { User } from "~/models/user";
export default eventHandler(async (ev) => {
const id = parseInt(getRouterParam(ev, "id") as string);
let dat = await User.find({
"favs.stories": {
$in: [id],
},
})
.select("-auth -email -ipLog -password")
.exec();
return dat.map((a) => a.toObject());
});