Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suggestion: using ids as key for objects, instead of using them inside object #28

Closed
moinologics opened this issue Jul 13, 2021 · 5 comments

Comments

@moinologics
Copy link

moinologics commented Jul 13, 2021

How would this feature be useful?
retrieving object by its id (primary key) in O(1) times instead of O(n) time.

Describe the solution you'd like

currently json file looks like --- { "data": [ { "id": 1, "k1": "v1" }, { "id": 2, "k2": "v2" }] }

it should looks like --- { "data": { "1": {"k1": "v1"}, "2": {"k2": "v2" } } }

now we can fetch single items by its key using db["1"] in O(1) time.

@mage1k99
Copy link

great suggestion. 👍

@fredysomy
Copy link
Member

@Adwaith-Rajesh what do you think.

@Adwaith-Rajesh
Copy link
Member

Nice, idea but this change should be a slow one. As currently there are like 1000 ppl using this monthly so when you suddenly change how data is represented this can cause issues with ppl who does not care about the version that they are using.
But this can be useful and if we are implementing it we can also get rid of the 'data' key.

@fredysomy
Copy link
Member

Yes. This will change the structure of data stored in db and as @Adwaith-Rajesh said. This will take some time as many projects store data in the current form and changing the structure can cause errors for them.

@fredysomy
Copy link
Member

#31
Thanks @Adwaith-Rajesh

closing this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants