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 {
|
export interface QuizTypeShort {
|
||||||
_id: string;
|
_id: string;
|
||||||
userId: string;
|
email: string;
|
||||||
title: string;
|
title: string;
|
||||||
created_at: Date;
|
created_at: Date;
|
||||||
updated_at: Date;
|
updated_at: Date;
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ const Users: React.FC = () => {
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{quizzes.map((quiz) => (
|
{quizzes.map((quiz) => (
|
||||||
<TableRow key={quiz._id}>
|
<TableRow key={quiz._id}>
|
||||||
<TableCell>{quiz.userId}</TableCell>
|
<TableCell>{quiz.email}</TableCell>
|
||||||
<TableCell>{quiz.title}</TableCell>
|
<TableCell>{quiz.title}</TableCell>
|
||||||
<TableCell>{new Date(quiz.created_at).toLocaleDateString()}</TableCell>
|
<TableCell>{new Date(quiz.created_at).toLocaleDateString()}</TableCell>
|
||||||
<TableCell>{new Date(quiz.updated_at).toLocaleDateString()}</TableCell>
|
<TableCell>{new Date(quiz.updated_at).toLocaleDateString()}</TableCell>
|
||||||
|
|
|
||||||
|
|
@ -41,10 +41,31 @@ class Admin {
|
||||||
|
|
||||||
const quizColl = conn.collection('files');
|
const quizColl = conn.collection('files');
|
||||||
|
|
||||||
const projection = { content: 0, folderName: 0, folderId: 0 };
|
const result = await quizColl.aggregate([
|
||||||
const result = await quizColl.find({}, projection).toArray();
|
{
|
||||||
|
$addFields: { userId: { $toObjectId: "$userId" } }
|
||||||
if (!result) return null;
|
},
|
||||||
|
{
|
||||||
|
$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 = {
|
let respObj = {
|
||||||
quizzes: result,
|
quizzes: result,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue