class Foo(Orm): pass
class Bar(Orm):
foo_id = Field(Foo)
So if I have a Foo instance, could I do something like:
f = Foo.create()
b = Bar.create(foo_id=f.pk)
print(b.pk) # 1
print(f.bar.pk) # 1
Basically, the __getattr__ algorithm would check Foo, if it couldn't find anything, then it would check the internal list of Orm children and see if something matches .model_name, and then it would see if that matching Bar class has a Field instance referencing Foo, then it would query using .one().
If you did f.bars then it would check .models_name and call .get().
So if I have a
Foo
instance, could I do something like:Basically, the
__getattr__
algorithm would checkFoo
, if it couldn't find anything, then it would check the internal list of Orm children and see if something matches.model_name
, and then it would see if that matchingBar
class has aField
instance referencingFoo
, then it would query using.one()
.If you did
f.bars
then it would check.models_name
and call.get()
.