I'm trying to use the rom Python ORM for storing objects in Redis.
I have the following model:
import rom
class Repository(rom.Model):
id = rom.PrimaryKey()
topics = rom.Json()
And I would like to create an instance where I can manually set the primary key, such as the following:
repo = Repository()
repo.id = 1337
repo.topics = ["topic1", "topic2"]
Nevertheless, when I try to do that I get the following error:
Traceback (most recent call last): [...] raise InvalidOperation("Cannot update primary key value") rom.exceptions.InvalidOperation: Cannot update primary key value
Essentially, I would like to be able to set the primary key's value so that in the database the entries can look like:
127.0.0.1:6379[1]> KEYS *
1) "Repository:243"
2) "Repository:1337"
3) "Repository:9001"
Rather than:
127.0.0.1:6379[1]> KEYS *
1) "Repository:1"
2) "Repository:2"
3) "Repository:3"