Open JCKodel opened 4 years ago
Thanks for the ideas!
To automatically generate relationship properties (list of bars in foo and an instance of foo in each bar).
Doing this based on CREATE TABLE
statements alone will probably result in inaccurate code. Just because there is some other table Bars
referencing Foos
, it doesn't necessarily mean that a list of Bar
is a logical property of Foo
. It would also break queries in moor files, since it's impossible to write a query having a List<Bar>
in a column.
allow we to apply one or more mixins:
We already have #114 as an issue for this.
Allow us to create queries and indexes outside .moor files (i.e.: don't use .moor files at all):
If it helps, you can write queries in a @UseMoor
and @UseDao
annotation (under the queries
parameter).
The syntax you're suggesting (having an annotated abstract method) would be hard to implement now, since moor will generate a superclass for you. To support abstract methods, it would have to generate an implementation for the interface you provide.
In general, I don't really see moor as an ORM. To me, it's more of a convenience framework around sql, so it inherits most of its concepts. I know there is interest in adding more ORM-like features, but those would also add a lot of complexity to the project. This includes automatic joins or subqueries (which we would need when generating a List<Bar>
) or customizing the generated classes. In my experience, attempting to prescind a relational model rarely works and can easily add a lot of complexity. See also What ORMs have taught me: just learn SQL and Embracing SQL without abstraction. I'm not saying that those features don't add value, but I'm reluctant to work on them if they're very complex.
I have a .moor file like this:
Now I need the class Foo to be generated as:
But it won't generate the
bars
property =\I know I can always use Dart to generate the table classes and use .moor only for indexes and queries, but I wonder if some of these would be possible:
1) To automatically generate relationship properties (list of bars in foo and an instance of foo in each bar).
2) To allow we to apply one or more mixins: Let's say we have this mixin:
And in the .moor file we could:
Notice the
WITH [ListOfMixins]
.That would generate the following:
3) Allow us to create queries and indexes outside .moor files (i.e.: don't use .moor files at all):