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

15 lines
333 B
TypeScript

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