P
Prisma•4d ago
Seb

using mongo -- insert document without any checks whatsoever?

I have a logging service and <some> of the data won't exactly quite match, especially the underlying types. I still want to have a bit of a mix between what I 100% expect to be there (like createdAt and such) and use prisma to query them -- but want to be able to not throw an error when trying to insert something that doesn't 100% match the schema (extra values basically); Is there a way to achieve this with prisma?
2 Replies
RaphaelEtim
RaphaelEtim•4d ago
Hi @Seb Would Json type work for your usecase? You can define a JSON field in your Prisma schema to store additional, unstructured data. This allows you to insert extra values without strictly matching the schema.
Working with Json fields (Concepts) | Prisma Documentation
How to read, write, and filter by Json fields.
Seb
SebOP•4d ago
hmmm, so kinda half-helps, the thing is a lot of the main 'relevan't stuff in a log is stores on .flow key of a main log object, I can have some certainty of what I can have on the top level, but if I make the whole .flow just Json -- I would lose a lot on the query side of things maybe combining types would be cool, say .flow is type Flow & Json, but that's a TS/JS thing 😄 but that might be relevant for postgres as well, to <partially> define some data types
Want results from more Discord servers?
Add your server