18 lines
471 B
JavaScript
18 lines
471 B
JavaScript
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) {
|
|
return createError({ statusCode: 500, statusMessage: 'Geen gebruikers zijn gevonden' })
|
|
}
|
|
|
|
const users = [];
|
|
for await (const doc of cursor) {
|
|
users.push(doc)
|
|
}
|
|
|
|
return users;
|
|
});
|