pysonDB-v2 icon indicating copy to clipboard operation
pysonDB-v2 copied to clipboard

feature request: allow custom key creation based on record data

Open Josverl opened this issue 3 years ago • 2 comments

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))

Josverl avatar Aug 28 '22 04:08 Josverl

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.

ybenitezf avatar May 31 '24 15:05 ybenitezf

The only option I found is to do monkey patching the functions above, or fork and make those mods yourself

Josverl avatar Jun 29 '24 09:06 Josverl