-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestScript.js
43 lines (37 loc) · 1.05 KB
/
testScript.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const { PrismaClient } = require("@prisma/client");
const prisma = new PrismaClient();
async function getUserData() {
try {
const userId = "cls4h198u0000k2vszg60ezm0"; // Replace with the actual user ID you want to query
// Find the user with the specified ID
const user = await prisma.user.findUnique({
where: {
id: userId,
},
include: {
persona: {
include: {
project: true,
},
},
},
});
// Extract and format the desired information
const userProjectsData = user.persona.reduce((result, persona) => {
persona.project.forEach((project) => {
result.push({
persona: persona.persona,
projectName: project.projectName,
minDesc: project.minDesc,
desc: project.desc,
hrefto: project.hrefto,
});
});
return result;
}, []);
console.log(JSON.stringify(userProjectsData, null, 2));
} catch (error) {
console.error("Error retrieving user data:", error);
}
}
getUserData();