Skip to content

Instantly share code, notes, and snippets.

@sultaniman
Created November 29, 2018 10:52
Show Gist options
  • Select an option

  • Save sultaniman/d977d68fe57ee09c510dd33e575f99cf to your computer and use it in GitHub Desktop.

Select an option

Save sultaniman/d977d68fe57ee09c510dd33e575f99cf to your computer and use it in GitHub Desktop.
Just sketching for declarative schemas
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