Polarcraft/web/server/api/team/members.js

18 lines
471 B
JavaScript
Raw Normal View History

2023-05-09 13:57:01 +02:00
export default defineEventHandler(async (event) => {
const user = await getAuth(event)
const usersColl = db.collection('users')
const cursor = usersColl.find({ 'team.id': user.team.id })
if((await usersColl.countDocuments({ 'team.id': user.team.id })) === 0) {
2023-05-09 16:01:19 +02:00
return createError({ statusCode: 500, statusMessage: 'Geen gebruikers zijn gevonden' })
2023-05-09 13:57:01 +02:00
}
const users = [];
for await (const doc of cursor) {
users.push(doc)
}
return users;
});