2023-12-20 17:23:31 -05:00
|
|
|
import { Band } from "@models/band";
|
|
|
|
import { IUser } from "@models/user";
|
2023-10-03 00:54:55 -04:00
|
|
|
|
2023-10-10 22:40:08 -04:00
|
|
|
export default cachedEventHandler(async (ev) => {
|
2023-10-03 00:54:55 -04:00
|
|
|
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;
|
|
|
|
});
|
|
|
|
});
|