Jaymon / prom

A PostgreSQL or SQLite orm for Python
MIT License
22 stars 4 forks source link

New things to pass into Field.__init__() #88

Closed Jaymon closed 1 year ago

Jaymon commented 4 years ago

jsonable

It would be cool if you could pass in jsonable=False and it would strip that field from a .jsonable() call, so...

class Foo(Orm):
    bar = Field(str, jsonable=False)

f = Foo(bar=4)
f.jsonable() # empty dict {} because bar would be removed

regex

if you pass in a regex then this will be ran during setting of the value, so...

class Foo(Orm):
    bar = Field(str, regex=r"[a-zA-Z]+")

Everytime bar gets set it would run regex to make sure bar conforms.