#prisma issue

70 messages · Page 1 of 1 (latest)

vernal crypt
#

i have absolutely no idea on how to make prisma work

when i use the provider that lets me use a file, i cannot use lists
when i use the provider that lets me use lists, it wont let me put a file as url

hearty sealBOT
#
  • 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
vernal crypt
#

respectively "sqlite" and "postgresql"

and this is what happens when i try to use lists in "sqlite"

dawn meadow
#

Makes sense tbh

wild field
#

sqlite doesn't have lists, postgresql isn't file based

dawn meadow
#

SQLite is a local db

vernal crypt
#

which one has both of the goodies

#

because i pretty much need lists

dawn meadow
#

Don’t store lists tbh

wild field
#

sqlite is the only one that is file based

dawn meadow
#

Use one-to-many (or similar) table relations

vernal crypt
dawn meadow
#

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

vernal crypt
#

lets say 40 different items

#

id need 40 different new refferences in my main table?

#

😭

dawn meadow
#

Huh?

vernal crypt
#

like

#

user {
item1: blablabla
item2: blablabla
...

dawn meadow
#

You make 40 rows in a different table that refer back to the single row in the original table

vernal crypt
#

oh wait so like

#

two different user profiles?

dawn meadow
#

That example is a one-to-one relationship

#

My recommendation is one-to-many

wild field
#

two different user profiles?
no, a table like UserItems {
userId: string
// other data
}

then you findMany in that table, using that userId

vernal crypt
#

im trying to pull this out but its twisting my neck

vernal crypt
wild field
#

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

vernal crypt
#

lemme screenshot how it looked with the lists

wild field
#

pretty sure you meant Tools[] instead of BigInt[] ?

vernal crypt
#

inventory is just like

#

item id and item amount

#

being the index and value

#

so a BigInt array is just fine

#

or list

wild field
#

ah, didn't see the tools row on User

wild field
#

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

vernal crypt
#

doesnt truly deletes a file

#

just writes over it

vernal crypt
#

the point is though

#

i dont know how to make it without the list thingy

#

my peanut brain wont collaborate

wild field
#

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

vernal crypt
#

guess i cant use enums[] too

#

so i gotta make ANOTHER submodel just for tool types

wild field
#

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

vernal crypt
#

just so i can put it in the db

wild field
#

yes

vernal crypt
#

alright