mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-09 23:48:36 +01:00
31 lines
727 B
TypeScript
31 lines
727 B
TypeScript
|
|
import { FeedbackModel } from '@schema/FeedbackSchema';
|
|
|
|
export default defineEventHandler(async event => {
|
|
|
|
const userData = getRequestUser(event);
|
|
if (!userData?.logged) return;
|
|
if (!userData.user.roles.includes('ADMIN')) return;
|
|
|
|
const feedbacks = await FeedbackModel.aggregate([
|
|
{
|
|
$lookup: {
|
|
from: 'users',
|
|
localField: 'user_id',
|
|
foreignField: '_id',
|
|
as: 'user'
|
|
}
|
|
},
|
|
{
|
|
$lookup: {
|
|
from: 'projects',
|
|
localField: 'project_id',
|
|
foreignField: '_id',
|
|
as: 'project'
|
|
}
|
|
},
|
|
])
|
|
|
|
return feedbacks;
|
|
|
|
}); |