#i set a type to number on the schema but appears as float64 on convex site/db
2 messages · Page 1 of 1 (latest)
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. |