Created
November 29, 2018 10:52
-
-
Save sultaniman/d977d68fe57ee09c510dd33e575f99cf to your computer and use it in GitHub Desktop.
Just sketching for declarative schemas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def add(field_name, type, **options): | |
| pass | |
| def create_index(field_name): | |
| pass | |
| def schema(table_name, *actions): | |
| return DatabaseTable(table_name) | |
| def timestapms(): | |
| pass | |
| posts = schema( | |
| "posts", | |
| add("title", models.CharField, null=True, blank=True), | |
| add("subtitle", models.CharField, null=True, blank=True), | |
| add("body", models.TextField, null=True, blank=True), | |
| create_index("title"), | |
| timestapms() | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment