You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At this moment in time primary keys have to ne numeric:
The id of the document has to be numeric
I like to use https://github.com/ramsey/uuid to generate UUIDs for my entities, but I'm not able to use them as my primary key because they are not numeric. Is there a reason why there's such a restriction?
The text was updated successfully, but these errors were encountered:
When refactoring the project there were some considerations that lead to that decision.
Backwards compatibility - Version 1 of SleekDB already had that restriction, so changes to that functionality need to be done well and backwards compatible.
Ease of use and implementation - Currently SleekDB internally increase a numeric counter by one for every "storing operation" to generate a unique id.
Consistency and abstraction - A half baked implementation could lead to inconsistent code and behaviour.
Additional Dependency - We try to avoid any kind of dependency. That's why we could offer a kind of API to hook into the standard behaviour but can't provide additional methods like with implementing ramsey/uuid
We thought about implementing a "string id" feature but didn't have the time to do so.
That said, If I remember correctly you can use the updateOrInsert() and updateOrInsertMany() methods to insert documents with your own ID.
You could extract that into it's own class and allow the user to implement their own functionality by providing a closure, custom class using an interface or something like that as a configuration option when creating a Store-Object.
Feel free to join our discord server if you need help or want to discuss details.
I certainly don't wat to introduce ramsey/uuid as a dependency in the codebase. I was just wondering why strings are not supported as primary keys. I'll join the Discord server to discuss this PR :)
At this moment in time primary keys have to ne numeric:
The id of the document has to be numeric
I like to use https://github.com/ramsey/uuid to generate UUIDs for my entities, but I'm not able to use them as my primary key because they are not numeric. Is there a reason why there's such a restriction?
The text was updated successfully, but these errors were encountered: