Jaymon / prom

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

one to many addon.MagicOrm mapping #82

Closed Jaymon closed 1 year ago

Jaymon commented 4 years ago

The idea would be if you had an orm class Foo then you could call Foo.bars and get all the Bar instances that contain the value in Foo.pk.

There are three variable name so look for:

The tough part is figuring out how to find the orm class, you can take the current module of the orm who called the property and work backwards, looking at each parent module and finding all the orm classes in that module and submodules of that module, this runs on the assumption that people group up their orm modules like we've always done (we always have a models module that contains all the orms) or something else? Not sure what.

Jaymon commented 1 year ago

You could do this using Orm.orm_classes and checking each orm_class.models_name

Jaymon commented 1 year ago

I actually did this sometime in the last few weeks in https://github.com/Jaymon/prom/commit/71dd2a0b5a945afe2601ac55158aca14ef716c86