Prisma Schema Single Type

Hi fellow cult members. I want to create a model for a 'single' type (not sure if that's the correct term) in my Prisma schema. My understanding is a Prisma Model is something that can be created multiple times. I don't want this. I want just a single instance of a model. It'll be something like: model PageText { title String description String } Is this possible?
8 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
code_sanchu
code_sanchuOP2y ago
Apologies for the lack of clarity, though I think you've understood what I want to do. My prisma schema, (which describes my db) has, for example, a model for a User, of which there can be many of. I want an entry/model which there can only be one of. I only ever want to have one of e.g. AllPagesText for the whole app/database. I hope this makes sense lol .
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
code_sanchu
code_sanchuOP2y ago
Sure. I'm building a cms for a site that has normal collections, e.g. images; it also has pages with various text elements on that I want the user to be able update themselves. This text changes page to page so I can't create a uniform model for PageText. I could just create a Model for AllPagesText with a single entry but would prefer not to do this.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
code_sanchu
code_sanchuOP2y ago
The shape of the model changes. For example: there's an 'albums' page which has a title and subtitle; there's also an about page which has a body of text, links, and more. I could make fields optional, but then my model wouldn't be typed as strongly as is ideal. If I was on the about page and querying my data, I'd have to assert the value of the data which seems like it should be unnecessary.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
code_sanchu
code_sanchuOP2y ago
I think the page type is good idea. I'm sure I'll come to a decent workaround, it's just I was wandering if the 'single type' was possible. I've used the headless CMS "Strapi" before and they had it on there, but it's not a big deal really. Thanks for your help.!
Want results from more Discord servers?
Add your server