Get numeric values of Decimal data types defined in schema. #23968
Replies: 1 comment
-
Hi @lucasdavidferrero 👋 Prisma uses the const data = await prisma.aikon_articulo.findMany();
data.forEach(item => {
item.aik_ar_cosnet = item.aik_ar_cosnet.toNumber();
}); |
Beta Was this translation helpful? Give feedback.
-
Question
When I run
prisma.aikon_articulo.findMany()
I get as a String the values of fields that were defined as Decimal. I know that under the hood Prisma is using decimal.js library.I'd like to get them as numeric values and not strings, just like the database stores it. Take the example of 'aik_ar_cosnet' field: SQL Stores the numeric value 109457.00, but Prisma library returns "109457" string. I'd like that Prisma returns the same value the database does.
Aside for that, I'm defining Decimal for those values that are used for currency. I don't know if this Prisma data type is correct to use in this situation. Maybe I could use another Prisma datatype?
How to reproduce (optional)
Expected behavior (optional)
Get numeric values from fields that were defined as Decimal in Prisma.
Information about Prisma Schema, Client Queries and Environment (optional)
OS: Windows
Database: MySQL
Node.js version: v18.14.1
Prisma version: 5.9.1
Beta Was this translation helpful? Give feedback.
All reactions