#prisma issue
70 messages · Page 1 of 1 (latest)
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
✅Marked as resolved by staff
respectively "sqlite" and "postgresql"
and this is what happens when i try to use lists in "sqlite"
Makes sense tbh
sqlite doesn't have lists, postgresql isn't file based
SQLite is a local db
which one has both of the goodies
because i pretty much need lists
Don’t store lists tbh
sqlite is the only one that is file based
Use one-to-many (or similar) table relations
wdym
Instead of adding a column with a List of items, make a new table that stores a single item and an id field that refers back to the original table
so if i have like
lets say 40 different items
id need 40 different new refferences in my main table?
😭
Huh?
like
user {
item1: blablabla
item2: blablabla
...
You make 40 rows in a different table that refer back to the single row in the original table
oh wait so like
two different user profiles?
That example is a one-to-one relationship
My recommendation is one-to-many
two different user profiles?
no, a table like UserItems {
userId: string
// other data
}
then you findMany in that table, using that userId
im trying to pull this out but its twisting my neck
how would i fit that into my user table?
you don't really need a user table, at least not for this
what I'm saying was, you'd have a table called "Item" which are the global definitions (eg item id, type, rarity) you can have another table "UserItem" which is the current state of an Item that a given User has, it'd have the user id, the item id, and other meta specific only to that item like amount, condition, etc
though I'm assuming that's how your db looks like because we don't have much info
lemme screenshot how it looked with the lists
pretty sure you meant Tools[] instead of BigInt[] ?
nope
inventory is just like
item id and item amount
being the index and value
so a BigInt array is just fine
or list
ah, didn't see the tools row on User
that seems like a pain to manage though
eg, what if you delete an item
it sounds like a one to many relation would be better
similar to what you have in your warning, cooldowns and tools rows
gonna do like HDD does
doesnt truly deletes a file
just writes over it
well if you say so
the point is though
i dont know how to make it without the list thingy
my peanut brain wont collaborate
if you do Model[] then it's not a list, it's a one to many relation, that's prisma's syntax
but BigInt isn't a model, it's a primitive type
hence why it'd need a list
because you can't do a one to many relation with a primitive type at the other side, that's not how it works
if you really want to use BigInts you'll need a list, or wrap it like in a union table or something
which would be more complex and you'd pretty much be making an actual one to many relation either way
oh okay
guess i cant use enums[] too
so i gotta make ANOTHER submodel just for tool types
I'm not sure about that, try it and see
maybe it can serialize it to json
sqlite doesn't support enums either way
so if that worked then they are using some kind of extra logic
discord's user ids are strings correct?
just so i can put it in the db
yes
alright