18 lines
461 B
JavaScript
18 lines
461 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: 'No users were found' })
|
||
|
}
|
||
|
|
||
|
const users = [];
|
||
|
for await (const doc of cursor) {
|
||
|
users.push(doc)
|
||
|
}
|
||
|
|
||
|
return users;
|
||
|
});
|