boolean-uk / team-dev-server-ex-2410-team3

0 stars 0 forks source link

Change response data in cohort #33

Open amos1969 opened 1 hour ago

amos1969 commented 1 hour ago

After deliberations with front-end, they want more user data in the responses from the cohort endpoints.

What needs to be done is to include them when querying the database:

    const cohorts = await dbClient.cohort.findMany({
      include: {
        users: {
          select: {
            id: true,
            role: true,
            email: true,
            profile: {
              select: {
                firstName: true,
                lastName: true,
                bio: true,
                githubUrl: true
              }
            }
          }
        }
      }
    })

Also in the /cohorts/addUser should return more data:

    const user = await dbClient.user.update({
      where: { id: userId },
      data: {
        cohorts: {
          connect: { id: cohortId }
        }
      },
      select: {
        id: true,
        role: true,
        email: true,
        profile: {
          select: {
            firstName: true,
            lastName: true,
            bio: true,
            githubUrl: true
          }
        }
      }
    })
amos1969 commented 1 hour ago

Approved