I'm trying to make two relationships:
- ProductsxColors
- ProductsxSizes
Products Table:
class Products extends Table{
IntColumn get idProduct => integer().autoIncrement()();
//more fields...
}
Colors Table:
class Colors extends Table {
IntColumn get idColor => integer().autoIncrement()();
TextColumn get name => text().withLength(min: 1, max: 100)();
TextColumn get value => text().withLength(min: 1, max: 100)();
}
Sizes Table:
class Sizes extends Table {
IntColumn get idSize => integer().autoIncrement()();
TextColumn get size => text().withLength(min: 1, max: 100)();
}
A Product can have many Sizes and Colors.
I've already read moor documentation, but only found examples for entities with one relationship.
Solved using queries.
First, add transactional tables:
Then, create a Dao for query
This generates the following methods:
the insert method goes this way: