Prisma does not automatically update interfaces

I am currently working on a Nest.js project with Prisma as my ORM. However, I have encountered an issue that needs to be addressed:

My User model is quite simple:

model User {
    id               String @id @default(uuid()) @db.Uuid

    firstName        String? @map("first_name") @db.Citext
    lastName         String? @map("last_name") @db.Citext
    phoneNumber      String? @map("phone_number") @unique
    email            String  @unique
    password         String
    twitter          String?
    linkedIn         String? @map("linked_in")
    personalWebsite  String? @map("personal_website")
    title            String?
    bio              String?
    tac              Boolean
    accountConfirm   Boolean @map("account_confirm") @default(false)

    verificationCode VerificationCodes[]
    confirmHashes    ConfirmationHashes[]
    session          Sessions?

    updatedAt DateTime @default(now()) @map("updated_at") @updatedAt @db.Timestamptz(6)
    createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)

    @@map("users")
}

The recent change I made was switching @@map("user") to @@map("users"). After performing the migration and generating interfaces, I noticed that although the table name in the database has been updated, the corresponding interfaces in the code remain unchanged. As a result, I am unable to use the following code snippet:

await this.prisma.users.create({...

An error message pops up stating -

TS2551: Property 'users' does not exist on type 'PrismaService'.
. It suggests using .user instead, but considering I already modified it in schema.prisma, this solution seems incorrect.

I have attempted various troubleshooting steps such as deleting the node_modules folder, reinstalling packages, and rebuilding multiple times without any success. Could there be a cache issue causing this problem? How can I resolve it?

Answer №1

@@map is used to modify the name of the database table, not the actual table created by Prisma along with its TypeScript interfaces.

Visit this link for more information on @@map

In your case, the User model will always be accessed through prisma.user. If you wish to access it using prisma.users, you need to change the model's name in Prisma.

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

I need help differentiating "namespace" from "static attributes" in TypeScript

Separating namespace from static properties in TypeScript can sometimes be tricky. error: 'ClassA' only refers to a type, but is being used as a namespace here. class ClassA { static ClassB = class { }; } type T = ClassA // ok type T = C ...

Encountering npm3 installation errors with typyings in Angular 2?

Each time I try to sudo npm install Angular 2 modules, everything updates and installs correctly. However, I encounter the following error when the typings install is attempted: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0 ...

In TypeScript, the 'fs' module can be imported using the syntax `import * as fs from "

import * as fs from "fs"; const image1 = Media.addImage(document, fs.readFileSync("new.png")); Here is the configuration from my tsconfig.json: "compileOnSave": false, "compilerOptions": { "importHelpers": true, "outDir": "./dist/out-tsc", ...

Angular Typescript error: Trying to assign a value to 'someProperty' property of an undefined object

Within my Article class, I have a property called Image which is structured like this: export class Article { public image:Image; public images: Image[]; } If I decide to comment out this.article.image = new Image(); in the following way: constru ...

The data passed into the child component via Input() retains its original value even after being modified within the child

While passing an object containing data length and an array of objects to a child component, I noticed a strange behavior. Even after changing the data in the child component and reloading the page, the edited property still persists. To visualize this is ...

MySQL Community Storage Schema

Currently, I have a setup where each community is stored in a single row with member names separated by commas. This works well for smaller, unchanging communities. However, as the communities grow larger - like one with 75,000 members - loading times be ...

React's memo and/or useCallback functions are not functioning as anticipated

Within my Home Component, there is a state called records, which I utilize to execute a records.map() and display individual RecordItem components within a table. function Home() { const [records, setRecords] = useState<Array<RecordType>>(l ...

Why does mapping only give me the last item when I try to map onto an object?

Why does mapping onto an object only give me the last item? Below is the object displayed in the console: 0: {Transport: 2} 1: {Implementation: 9} 2: {Management: 3} When I use ngFor, it only provides the last item const obj = this.assigned_group; // r ...

How can I iterate over nested objects using ngFor in Angular HTML?

We have a data object stored on our server structured like this; { "NFL": { "link": "https://www.nfl.com/", "ticketPrice": 75 }, "MLB": { "link": "https:// ...

Tips for determining if an HTMLElement has already been created

One issue I'm facing is with a third party component that emits an "onCellEdit" event and passes a cell element as a parameter. My goal is to automatically select the entire text in the input element generated inside this cell when the event occurs. ...

Issue: Unable to locate a change supporting element '[object Object]' of the type 'object - Angular 7'

An angular service has been created for the specified purpose: CheckTicket(barcode, codEspec, diaHoraEspec):Observable<Ticket[]>{ //read ticket return this.http.get<Ticket[]>(`${this.checkticket_url}${barcode}?token=${this.token}&a ...

Record the variable as star symbols in the VSTS Extension

I am working on a VSTS extension using Typescript and utilizing the vsts-task-lib Currently, I am encountering an issue with the execSync function, which displays the command being executed. However, I need to hide a token obtained from a service by displ ...

Using TypeScript and controllerAs with $rootScope

I am currently developing an application using Angular 1 and Typescript. Here is the code snippet for my Login Controller: module TheHub { /** * Controller for the login page. */ export class LoginController { static $inject = [ ...

Erasing information and then moving to the identical webpage

The HTML Content : <td> <a (click)="onDelete(item.id)"> <i class="material-icons" style="font-weight:bold; font-style:inherit ;color: rgba(247, 37, 37, 0.884);"> delete_outline </i> </a> </td> The correspondin ...

Error: The type 'Promise' cannot be assigned to the type 'Model' in Angular 2 when working with Firebase

I have a method in my bug service that retrieves a single record from Firebase based on the bugId provided: // This method is located in bugservice.ts getBug(bugId: string): Promise<Bug> { return this.bugsDbRef .child(bugId) ...

Can someone guide me on how to display only the most recent form submission in a form using React and JavaScript? Appreciate your help

Currently, I'm facing a challenge with displaying the latest form submission below a form on my page. Instead of showing all form submissions, I only want to display the most recent one. I'm seeking advice on how best to tackle this issue. If it ...

What is the best way to retrieve HTML content using an Angular method?

Okay, so the title might not be the greatest...but I couldn't think of anything better: I want to emphasize search keywords in the result list...that's why I'm having trouble with this problem. CSS: .highlightText{ font-weight: bold; } In ...

Using TypeScript's `extend` keyword triggers an ESLint error when attempting to extend a generic type

I am dealing with numerous models that include additional meta data, which led me to create a generic type for appending them to the models when necessary: type WithMeta<T> = T extends Meta; However, I encountered an error stating: Parsing error: &a ...

Attempting to interpret and apply information extracted from a JSON document

I'm having trouble importing a JSON file into my Angular TypeScript page file that has this structure: { "latitude": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], "longitude": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], " ...

Sending an ID from an array within a *ngFor loop to a different component in Angular: a step-by-step guide

I have a collection of items that I loop through using ngFor. My goal is to pass all its attributes to another component. I attempted to accomplish this with the following code: *ngFor='let item of postList [routerLink]="['/detailed-post&ap ...