19 lines
507 B
TypeScript
19 lines
507 B
TypeScript
import { Band } from "@models/band";
|
|
import { IUser } from "@models/user";
|
|
|
|
export default cachedEventHandler(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;
|
|
});
|
|
});
|