angel-dart / angel

[ARCHIVED] A polished, production-ready backend framework in Dart for the VM, AOT, and Flutter.
https://angel-dart.dev/
MIT License
1.06k stars 67 forks source link

Allow disabling fetching of relations #233

Closed thosakwe closed 3 years ago

thosakwe commented 4 years ago

This issue was originally created by @thosakwe here, before being automatically moved: https://github.com/angel-dart-archive/orm/issues/38


Just for the purpose of sending-as-few-queries-as-possible-and-only-the-ones-which-are-necessary

i.e.

@serializable
@orm
abstract class _Foo extends Model {
  @hasMany
  List<Bar> bars;
}

// Do NOT fetch from `bars` table
var query = new FooQuery(withRelations: false);
thosakwe commented 4 years ago

@thosakwe commented:

Finally found a solution. By simply adding another parameter - List<String> trampoline to compile, the system can easily determine which tables have already been queried, and prevent querying them again.

Or, perhaps it can just be a parameter to constructors. Depends which works best. Ultimately, though, it'll make many-to-many work again.