<@U0RQY0KK5> Per the above discussion, are JSON fi...
# prisma-whats-new
d
@nilan Per the above discussion, are JSON fields non-queryable?
n
@dk0r JSON fields are indeed queryable. I wonder why you want to model first name, last name etc as a list of Strings rather than separate String fields. What benefit are you hoping to get out of this?
d
@nilan, I'm new to backend and databases and it just seemed more orderly to have an object containing related info (names, address, dateofBirth, etc) rather than having serparate fields for each
n
I'd advice for using separate fields instead. Sometimes you are interested in JUST the street name, or JUST the city, and not the complete address
if you want to "group" the information together, defining a new
Address
type for example would be my preferred choice
d
and then just create a user => address relation?
alright, thanks nilan
n
exactly, a one-to-one relation most probably
d
@agartha btw, apparently json objects are queryable ^
@nilan, what's the use case for a json object then?
n
I think it's a terminology thing. To put it more clearly:
a
@dk0r I explained what I meant by queryable
n
- json fields can be returned to the client by including them in the GraphQL query (as you would expect) - no filters exist for json fields. you cannot query all items that have a certain json property key/value in one of their fields
👍🏻 1
a
With queryable, I meant can be used for filtering, ordering, etc. [22:58] they will show up in query results of course [22:59] If you want to query a list of users ordered by last name, and last name is part of a JSON field, you can't do that
d
what's a practical/common use case for a json field?
n
a typical use case is to store data whose structure is not necessarily known beforehand or differs between different nodes
it's basically a super simple/flexible way to store key/pair values
a
I use it for two things mostly: user defined fields (use case 1), and payload for my message queue Type (use case 2).