const gameTableName = 'games';
@Entity(tableName: gameTableName)
class Game {
const Game({
required this.id,
required this.alias,
required this.name,
});
@primaryKey
final String id;
final String alias;
final String name;
}
B:
const gamesCategoriesTableName = 'games_categories';
@Entity(tableName: gamesCategoriesTableName)
class GamesCategory {
const GamesCategory({
required this.id,
required this.name,
required this.alias,
});
@primaryKey
final String id;
final String name;
final String alias;
}
C:
const gamesInCategoryTableName = 'game_in_categories';
@Entity(
tableName: gamesInCategoryTableName,
foreignKeys: [
ForeignKey(
childColumns: ['categoryId'],
parentColumns: ['id'],
entity: GamesCategory,
),
ForeignKey(
childColumns: ['gameId'],
parentColumns: ['id'],
entity: Game,
),
],
)
class GameInCategory {
const GameInCategory({
this.id,
required this.order,
required this.categoryId,
required this.gameId,
});
@PrimaryKey(autoGenerate: true)
final int? id;
final int order;
final String categoryId;
final String gameId;
}
I write:
@DatabaseView(
'''
SELECT
gic.order as order,
gc.*,
g.*
FROM
$gamesInCategoryTableName as gic
INNER JOIN
category as gc ON gic.categoryId = gc.id
AS game INNER JOIN
game as g ON gic.gameId = g.id
''',
viewName: 'game_with_category',
)
class GameWithCategory {
const GameWithCategory({
required this.category,
required this.order,
required this.game,
});
final int order;
final GamesCategory category;
final Game game;
}
@Database(
version: 1,
views: [GameWithCategory],
entities: [GamesCategory, Game, GameInCategory],
)
abstract class AppDatabase extends FloorDatabase {
GamesCategoriesDao get gamesCategoriesDao;
GamesDao get gamesDao;
GameInCategoryDao get gameInCategoryDao;
}
But on generation I have errors:
Column type is not supported for GamesCategory.
Column type is not supported for Game.
How can I get class for use with DAO like this:
@Query('SELECT * FROM game_with_category')
Future<List<GameWithCategory>> getGamesWithCategory();
Hello I have 3 table A:
B:
C:
I write:
But on generation I have errors:
Column type is not supported for GamesCategory. Column type is not supported for Game.
How can I get class for use with DAO like this: