2017-06-18 22:40:23 +00:00
|
|
|
class Relationship {
|
|
|
|
final String localKey;
|
|
|
|
final String foreignKey;
|
|
|
|
final String foreignTable;
|
|
|
|
final bool cascadeOnDelete;
|
|
|
|
|
|
|
|
const Relationship._(
|
|
|
|
{this.localKey,
|
|
|
|
this.foreignKey,
|
|
|
|
this.foreignTable,
|
|
|
|
this.cascadeOnDelete});
|
|
|
|
}
|
|
|
|
|
|
|
|
class HasMany extends Relationship {
|
|
|
|
const HasMany(
|
2017-06-24 21:21:32 +00:00
|
|
|
{String localKey: 'id',
|
2017-06-18 22:40:23 +00:00
|
|
|
String foreignKey,
|
|
|
|
String foreignTable,
|
|
|
|
bool cascadeOnDelete: false})
|
|
|
|
: super._(
|
|
|
|
localKey: localKey,
|
|
|
|
foreignKey: foreignKey,
|
|
|
|
foreignTable: foreignTable,
|
|
|
|
cascadeOnDelete: cascadeOnDelete == true);
|
|
|
|
}
|
|
|
|
|
|
|
|
const HasMany hasMany = const HasMany();
|
|
|
|
|
|
|
|
class HasOne extends Relationship {
|
|
|
|
const HasOne(
|
2017-06-24 21:21:32 +00:00
|
|
|
{String localKey: 'id',
|
2017-06-18 22:40:23 +00:00
|
|
|
String foreignKey,
|
|
|
|
String foreignTable,
|
|
|
|
bool cascadeOnDelete: false})
|
|
|
|
: super._(
|
|
|
|
localKey: localKey,
|
|
|
|
foreignKey: foreignKey,
|
|
|
|
foreignTable: foreignTable,
|
|
|
|
cascadeOnDelete: cascadeOnDelete == true);
|
|
|
|
}
|
|
|
|
|
|
|
|
const HasOne hasOne = const HasOne();
|
|
|
|
|
|
|
|
class BelongsTo extends Relationship {
|
2017-06-24 21:21:32 +00:00
|
|
|
const BelongsTo(
|
|
|
|
{String localKey: 'id', String foreignKey, String foreignTable})
|
2017-06-18 22:40:23 +00:00
|
|
|
: super._(
|
|
|
|
localKey: localKey,
|
|
|
|
foreignKey: foreignKey,
|
|
|
|
foreignTable: foreignTable);
|
|
|
|
}
|
|
|
|
|
|
|
|
const BelongsTo belongsTo = const BelongsTo();
|