Skip to content

record is missing the primary key but defined in the model ? #1717

Answered by ldiebold
SPG87 asked this question in Q&A
Discussion options

You must be logged in to vote

At a glance, it looks like you may need a client_id on the "Projects" model. I'm going to rewrite some of this code, and change the naming to make it more inline with what you'd usually see with PiniaORM. Specifically, changing this line:

@BelongsTo(() => clients, 'client_id') declare client_id: clients

to this:

@BelongsTo(() => Client, 'client_id') declare client: client

ProjectModel.ts (note, this is usually pascal, singular. You may also want to drop the word Model so its reads Project.ts)

import { Model } from "pinia-orm";
import { Attr, BelongsTo, Bool, Num, Str, Uid } from 'pinia-orm/dist/decorators'
import Client from '@app/stores/pinia-orm/models/ClientModel'

export default class 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@SPG87
Comment options

Answer selected by SPG87
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants