mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
FIX - email au lieu du userId
This commit is contained in:
parent
3124d23df3
commit
c4b90a8ee5
3 changed files with 27 additions and 6 deletions
|
|
@ -12,7 +12,7 @@ export interface QuizType {
|
|||
|
||||
export interface QuizTypeShort {
|
||||
_id: string;
|
||||
userId: string;
|
||||
email: string;
|
||||
title: string;
|
||||
created_at: Date;
|
||||
updated_at: Date;
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ const Users: React.FC = () => {
|
|||
<TableBody>
|
||||
{quizzes.map((quiz) => (
|
||||
<TableRow key={quiz._id}>
|
||||
<TableCell>{quiz.userId}</TableCell>
|
||||
<TableCell>{quiz.email}</TableCell>
|
||||
<TableCell>{quiz.title}</TableCell>
|
||||
<TableCell>{new Date(quiz.created_at).toLocaleDateString()}</TableCell>
|
||||
<TableCell>{new Date(quiz.updated_at).toLocaleDateString()}</TableCell>
|
||||
|
|
|
|||
|
|
@ -41,10 +41,31 @@ class Admin {
|
|||
|
||||
const quizColl = conn.collection('files');
|
||||
|
||||
const projection = { content: 0, folderName: 0, folderId: 0 };
|
||||
const result = await quizColl.find({}, projection).toArray();
|
||||
|
||||
if (!result) return null;
|
||||
const result = await quizColl.aggregate([
|
||||
{
|
||||
$addFields: { userId: { $toObjectId: "$userId" } }
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "users",
|
||||
localField: "userId",
|
||||
foreignField: "_id",
|
||||
as: "user"
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: "$user"
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
_id: 1,
|
||||
email: "$user.email",
|
||||
title: 1,
|
||||
created_at: 1,
|
||||
updated_at: 1
|
||||
}
|
||||
}
|
||||
]).toArray();
|
||||
|
||||
let respObj = {
|
||||
quizzes: result,
|
||||
|
|
|
|||
Loading…
Reference in a new issue