Despite saving the user in both the Prisma model for user and session, the value is still not showing up as expected

Image of the session model being accessed in the file When attempting to retrieve the user from the session model in MongoDB using Prisma, only the user value is not displaying ( id: string; sessionToken: string; userId: string; expires: Date;). I have stored the user in the session model but it is not appearing as expected.

Here is the schema.prisma file:

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "mongodb"
  url      = env("DATABASE_URL")
}

model Product {
  // Model fields
}

// Other models

model User {
  // Model fields
}

model Session {
  // Model fields
}

model VerificationToken {
  // Model fields
}

This is where the user access is attempted:

// Code snippet for accessing user from session

Error message received: Property 'user' does not exist on type 'UserMenuButtonProps'.ts(2339)

Answer №1

Consider utilizing destructuring for your properties:

UserMenuButton({ session }: UserMenuButtonProps)

The properties are supplied as a reference to the object, so you can either destructure it in the parameter, or change session to props and access props.session.user instead.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Navigating Next.js: Mastering the art of localStorage Access

Currently, I am developing my first member area using next.js. My goal is to store some data in localStorage (such as token, expiresAt, userInfo), which will eventually be moved to an http-only cookie. The code below is generating the error: "LocalStorage ...

Implementing a Next.js server-side permanent redirection instead of displaying a 404 error page

My Next.js application consists of three routes: /home, /about, and /contact. When a user accesses a route that doesn't exist, Next.js automatically redirects them to the 404 page. However, I want to change this behavior and permanently redirect use ...

Error message encountered: The object contains unknown key(s): 'images' at "experimental" - Error in Next.js version 14.1.0

Currently, I am in the process of deploying my nextJs project on github pages and following a tutorial. I encountered an issue while trying to execute a pipeline in github, receiving an error message. Below is the code snippet from my next.config.mjs fil ...

Experience a unique custom layout using AppRouter in Next.js version 13, with the added

My goal is to encapsulate the _app.js file within a custom layout, similar to what I have done before. This way, I can include a Navbar at the top and wrap everything else within a container: //layout.js file import { Container } from 'react-bootstrap ...

Guide on integrating the plyr npm module for creating a video player in Angular2

Looking to implement the Plyr npm package in an Angular 6 application to create a versatile video player capable of streaming m3u8 and Youtube videos. The demos on their npm page are written in plain JavaScript, so I need guidance on how to integrate it in ...

Unusual conduct exhibited by a 16th version Angular module?

I've created a unique component using Angular 16. It's responsible for displaying a red div with a message inside. import { ChangeDetectionStrategy, Component, Input, OnInit, } from "@angular/core"; import { MaintenanceMessage } ...

Unable to make changes to the document

Having trouble updating a document by ID using mongoose and typescript. I'm testing the api and passing the id as a parameter. I've experimented with different methods of updating by ID, but for some reason, it's not working. Can update by ...

When TypeScript generator/yield is utilized in conjunction with Express, the retrieval of data would not

Trying to incorporate an ES6 generator into Express JS using TypeScript has been a bit of a challenge. After implementing the code snippet below, I noticed that the response does not get sent back as expected. I'm left wondering what could be missing: ...

Limit access to the sign-in and registration page once authenticated with NextAuth in Next.js

I am currently working on implementing a middleware in NextAuth.js to restrict access to the sign-in and sign-up pages after authentication. Here is the code snippet I have so far: import { getToken } from "next-auth/jwt"; import { NextResponse } from ...

Ways to incorporate environment variable in import statement?

In my Angular v5 project, I have a situation where I need to adjust the import path based on the environment. For example, I have an OwnedSetContractABI file located in different folders for each environment - dev and production. In dev environment, the ...

"Utilize the createReducer function with builder syntax to handle callbacks

Having trouble using createReducer with the builder syntax to update the auth state based on user login success or failure. Running into TS2769 error specifically in the second builder.addCase where adjusting the state for failed logins. Seeking assistance ...

Adding an Icon to the Angular Material Snackbar in Angular 5: A Step-by-Step Guide

I recently started using Angular and have incorporated Angular Material Design for my UI elements. Within my application, I am utilizing a snackbar component. However, I am facing difficulty in adding an icon inside the snackbar despite trying various so ...

Tips for incorporating a mesh into Forge Viewer v6 with Typescript

Is there a way to add meshes to Forge Viewer v6 using Type script? I've tried various methods that worked with v4, but I'm encountering issues now. private wallGeometry: THREE.BoxBufferGeometry; drawWalls() { ...

Navigate to a different route in AntD Table by clicking on it

I am currently implementing React Router in my navigation component. My goal is to enable users to navigate from screen Y to screen X when they click on a table element. In the past, I achieved this by using "this" command but it seems that it does not ...

Error encountered in NextJS API: "TypeError: res.status is not a function"

Background In my development environment, I am using NextJS v11.1.1-canary.11, React v17.0.2, and Typescript v4.3.5. To set up a basic API endpoint following the guidelines from NextJS Typescript documentation, I created a file named login.tsx in the pag ...

What is the most effective method of utilizing union or extend in TypeScript when faced with a comparable scenario?

I have a function that takes in two different types of objects: const canBeGenericOrDefaultData = { id: 123, pointData: { square: 'x145', triangle: 'y145' } } function submitHandler(canBeGenericOrDefaultData: AllTheDatas | G ...

What is the maximum number of concurrent queries supported by MongoDB?

Is there a maximum number of concurrent queries that can be executed by MongoDB in one second? I am currently developing an API that sends 300 queries per request to MongoDB. If there are 100 client requests within a second, this would result in 100 x 30 ...

Browser fails to display input value when altered

I have noticed that when the value of the Input element changes, the browser does not display the updated value. However, you can verify this change by inspecting the DevTools in the browser. I am curious as to why the actual value of the Input element is ...

Can my https.post function determine the specific API function to call?

Here is the code for my service file that interacts with mongoDB: import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { filter, isEmpty, map } from 'rxjs/operators'; import { ...

Tips for efficiently storing nested data in mongoDB with mongoosejs?

Storing sample data in mongodb with the help of postman API testing. { "id": "242kd", "user_id": "123gsgshsghgshgs6", "product_id_quantity": [ { "product_id": 8, "quant ...