You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
By clicking “Sign up for GitHub”, you agree to our
terms of service
and
privacy statement
. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
"Problem"
A JSON field in a database might contain a lot of data that you don't necessarily want to return each time you read a record - e.g. unstructured analytics data. Would it be possible to have some way to include/omit a JSON field, or (depending on db support) select what part of a JSON field you want to include in the response?
Additional context
Prisma folks:
https://prisma-company.slack.com/archives/CFM8D5VHC/p1589369382107900
matthewmueller, aakashkag, luxaritas, sehmaschine, danwetherald, darrylyoung, schickling, cedrickring, martijnburger, meotimdihia, and 57 more reacted with thumbs up emoji
DavidVaness and mrowles reacted with rocket emoji
binajmen, rohanrajpal, benhason1, shawshankkumar, sacru2red, tobiasscheel-dev, j127, vimtor, Josh-a-e, DavidVaness, and 3 more reacted with eyes emoji
All reactions
Quick brain dump of thoughts for slicing unstructured data:
Postgres supports subqueries on unstructured data:
https://www.postgresql.org/docs/9.3/functions-json.html
. So you could do
select '{"a":1,"b":2}'::json->>'b'
and get
2
. We could consider exposing that capability to the client.
For databases that do not support this capability, we could return the full contents of this JSON column and slice inside with the clients themselves.
Since you don't know the fields or types in advance with unstructured data, you'd lose type-safety doing this, so we should encourage folks to apply
some
structure to their unstructured data. For handling structured data, we'll likely introduce the concept of
embeds
.
This is exactly the use case that I am working on. I am transfering way to much data from the db json field, while I just need a few properties from the object.
Example database query (postgres):
select p.json->>'email' as email from party p
Looking for something in the prisma client like:
prisma.party.findMany({ select: { json->>'email': true } })
Currently I can only do:
prisma.party.findMany({ select: { json: true } })
Looking for something in the prisma client like:
prisma.party.findMany({ select: { json->>'email': true } })
That would be awesome 👍
I have large datasets which need to be saved in the db. Creating 100s of models for a dataset and maintaining it is a monumental task. So I decided to give JSON a go and it is working decent enough. However, data retrieval is a pain.
One call gives 40k lines of JSON when only a part of it is needed ^_^"
Though useful, I want to avoid using raw queries. This feature would be awesome! Any ETA on this?