Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prisma 2 - Map int column to enum

At the database I've a column that is from type Integer that can only contain the following values Active = 1, Temporary=7, Deleted=10. Can these values be mapped from the server to a enum and the database is storing it within a integer column?

According to the documentation I can only use enums when the values are also stored as enums in the database.

like image 956
ProV Avatar asked Oct 21 '25 03:10

ProV


2 Answers

Have you tried to look at @map? Using your question as input, the enum would look like this.

enum YOU_ENUM {
    Active  @map(1)
    Temporary @map(7)
}
like image 140
armandopadilla Avatar answered Oct 23 '25 17:10

armandopadilla


I think it is impossible at the time of writing.

like image 25
Meo Beo Avatar answered Oct 23 '25 17:10

Meo Beo