When I store the ID it disappears with some numbers

Asked

Viewed 9 times

0

I was making an app and in it I needed to store the id which is pretty great type this was my id 173782035419103232 but when arriving at the database it modifies to 173782035419103230 as I can do for it not round the number (I use the lib Mongodb/Mongoose)

1 answer

0

I see two exits:

  1. Save your ID as String, which will make sense if you won’t do arithmetic operations on the bank like this value (add, average...).
  2. Save your value as Decimal128 which is the data type for "big" numbers in mongodb (you need to use version 3.4 of Mongo to use this data type).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.