feat(api): add an endpoint to retrieve the users who have favourited a specific story

This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2023-10-03 01:18:12 -04:00
parent 6b5b01fdd6
commit f0346ebdbd
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C

View File

@ -0,0 +1,13 @@
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());
});