#i set a type to number on the schema but appears as float64 on convex site/db

2 messages · Page 1 of 1 (latest)

remote escarpBOT
#

Hi @dire socket. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

In Convex, the v.number() validator corresponds to the Float64 type. As per the Convex documentation on data types (https://docs.convex.dev/database/types#convex-values), Float64 is the Convex type that corresponds to the JavaScript number type.

So, when you define a field with v.number() in your schema, it is expected that it will appear as v.float64() in the Convex database. This is because JavaScript's number type is a floating-point number, and Convex uses Float64 to represent this type.

Here's the relevant part of the table from the documentation:

Convex Type TS/JS Type Example Usage Validator for Argument Validation and Schemas json Format for Export Notes
Float64 number (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type) 3.1 v.number() number / string Convex supports all IEEE-754 double-precision floating point numbers (such as NaNs). Inf and NaN are JSON serialized as strings.

So, there's no issue with your schema. The price field being represented as v.float64() in the Convex database is the expected behavior when you define it as v.number() in your schema.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: