PrismaP
Prisma13mo ago
3 replies
PIat

Using a JSON field as an id

Hello! I want to cache API results in the database and I was wondering if it'd be possible to use the
id
in the JSON field as an id, perhaps through @@id or some client extension?
Solution
Hello @PIat 👋

You could store the API result in a JSON field and also store the ID you want to use in a separate field marked as @id. However it won't be possible to skip having an
id
field altogether.

You can use a client extension to manipulate the data before saving it to the database. So essentially, getting the
id
from JSON and using the same value in the actual
id
column
Was this page helpful?