quick.db icon indicating copy to clipboard operation
quick.db copied to clipboard

Avoid conversion while getting values

Open Shqrp opened this issue 4 years ago • 4 comments

Hello! I'm currently using this version of quick.db and there is a problem when getting values: for example I have the ID 842846562882813982 set to the key logchannel. Whenever I set it, it's all fine, but whenever I try and get the value it just gets converted to a number, and because of the JSON.parse precision limit it returns 842846562882814000. Looking at the source code, it looks like this is a problem also for normal quick.db. So I'm asking if the conversion can be avoided in any way.

EDIT: forgot to tell that json-bigint can be used as a substitute for the built-in JSON namespace.

Shqrp avatar May 22 '21 06:05 Shqrp

You shouldn't be using such long numbers imo. Save as string and use it.

zyrouge avatar May 29 '21 14:05 zyrouge

The problem is that whenever I try to save it, it saves as string. But whenever I get it, it converts to number.

Shqrp avatar May 31 '21 06:05 Shqrp

I think I may have found a solution: just add a string of characters before the ID and it will get picked as a string overall. But this should be a temporary solution, it can't be like this. So if it's possible to save IDs as keys/values that would be amazing.

Shqrp avatar May 31 '21 06:05 Shqrp

I doubt https://github.com/DevSnowflake/quick.db/blob/0aee816124a8ab99f8e3964ef8046076bebe4c12/src/Database.js#L137 line as the cause of parsing it twice (stringified data -> parsed data (string) -> parsed again (number)). Definitely needs to be fixed imo.

zyrouge avatar Jun 02 '21 06:06 zyrouge