CodeDredd / pinia-orm

The Pinia plugin to enable Object-Relational Mapping access to the Pinia Store.
https://pinia-orm.codedredd.de/
MIT License
452 stars 39 forks source link

If primary key is called '@id' then using .save will cause error #1839

Closed roy1345 closed 6 months ago

roy1345 commented 6 months ago

Environment

No response

Reproduction

-

Describe the bug

When using "repo.save(object)" with an object that has the primary key set to '@id' instead of default "id" the following error occurs:

Error: [Pinia ORM] The record is missing the primary key. If you want to persist record without the primary key, please define the primary key field with the uid attribute.

Defining the data manually works: "repo.save({'@id': object['@id'])"

Additional context

No response

Logs

No response

CodeDredd commented 6 months ago

Can you please provide a reproduction please or at least the rawData your passing the model definition 🙏

roy1345 commented 6 months ago

I just figured out that I was actually missing the '@id' primary key. So my bad. This can be closed.