P
Prisma•6d ago
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...
Jump to solution
2 Replies
Solution
Nurul
Nurul•6d ago
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
PIat
PIatOP•5d ago
Alright! Thank you a lot! Sounds like a plan!

Did you find this page helpful?