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

Find a way to generate automatically PrimaryKeys instead of coding them #8

Closed
sorasful opened this issue Nov 15, 2021 · 1 comment
Closed

Comments

@sorasful
Copy link

IMHO, It would be essential that PrimaryKey() generates automatically an id, it could even depend on the type we are passing, for example :

class Employee(DataBaseModel):
    id: str = PrimaryKey()  # could use uuid.uuid4()
    id: int = PrimaryKey()  # could use random.randint(0, 9e99) (just an example, would need something better)

A possibility would also to set PrimaryKey as Optional, what do you think ?

@codemation
Copy link
Owner

I probably answered this question in #5 , where you would need to use PrimaryKey(default=) passing in an argument-less method that will be used to generate almost any type of data at instantiation.

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

2 participants