Ecker
03/16/2019, 9:04 AMnull for 90% of users. — So I've usually stored this as a JSON column in MySQL, which did work great back then. But with Prisma, graphql and graphql-bindings I see that this JSON approach would lose a lot of the power of graphql, making me have to do lots of manual validation on this json object. So I'm wondering how to best deal with lots of these meta values in Prisma?
type User {
id: ID! @unique
email: String! @unique
password: String!
meta1: Json! # ← My traditional approach, any data, any structure)
meta2: UserMeta! # ← Thinking this might be better?
}
type UserMeta {
role: UserRole!
newsletter: Boolean
# …etc, lots of other fields
}
enum UserRole {
MEMBER,
SUPER
}
But I still kinda dislike that the UserMeta might grow to 20+ columns, and most of those columns will be null or the default value for most users.jblevins
03/16/2019, 9:10 AMArnab
03/16/2019, 10:47 AMA, B, C for instance and make them subtypes of user (say BasicUser). Additionally, make User an interface,Arnab
03/16/2019, 10:48 AMEcker
03/16/2019, 12:37 PMEcker
03/16/2019, 12:37 PMFran Dios
03/17/2019, 11:04 AMArnab
03/17/2019, 12:13 PMEcker
03/17/2019, 10:27 PM