Mysql has the different integer datatype like, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT. Is there any way to detect the number is falling under which data type in JavaScript?
-
i would just hard code it with greater than and less thanRoland Starke– Roland Starke2019-09-06 15:01:35 +00:00Commented Sep 6, 2019 at 15:01
-
@RolandStarke — That could tell you the smallest DB datatype that would hold the number you had, but it wouldn't tell you the actual datatype.Quentin– Quentin2019-09-06 15:02:39 +00:00Commented Sep 6, 2019 at 15:02
Add a comment
|
2 Answers
JavaScript only has one datatype for numbers: Number
(BigInt is proposed for a future version of JS).
So, all else being equal: You can't.
Your database API might provide a mechanism that would expose that information, but it would depend on the database API you were using.
1 Comment
mkHun
Thanks @Quentin. Actually I am creating the YAML file by reading the CSV input (using node js). So in the
type attribute I have to mention the number data type.