import { Band } from "~/models/band"; import { IUser } from "~/models/user"; export default eventHandler(async (ev) => { let bands = await Band.find({ _id: { // $not: {name: ""}, $nin: (ev.context.currentUser as IUser)?.hiddenBands || [], }, }).exec(); return bands .filter((a) => a.name != "") .sort((a, b) => { if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) return 1; if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) return -1; return 0; }); });