pysonDB-v2
pysonDB-v2 copied to clipboard
feature request: allow custom key creation based on record data
I would like to be able to create an id by either specifying the id when adding, or by creating the id based on the record data passed in.
While it is currently possible to add a custom id, the _id_generator method is not passed the new object.
While it is simple to override the ._id_generator itself ,
In the current implementation I would also need to override the .add and .add_many methods to pass in the new record object.
is there reason not to pass in the data ?
# def add / add_many
...
_id = str(self._id_generator(data))
I have some data in json format that I'd like to migrate to pysonDB. However, I don't want to migrate the ids that I've already created.
Is there a way to create custom ids based on the record data? This would be a stopper for me because I don't want to have to change the ids that I've already created.
The only option I found is to do monkey patching the functions above, or fork and make those mods yourself