TableConstraint.fromMap constructor
TableConstraint.fromMap(
- Map<String, dynamic> map
)
Implementation
factory TableConstraint.fromMap(Map<String, dynamic> map) {
switch (map['type']) {
case 'primary_key':
return PrimaryKeyConstraint(null, map['column']! as String);
case 'foreign_key':
return ForeignKeyConstraint(
null,
map['column']! as String,
(map['target']! as String).split('.')[0],
(map['target']! as String).split('.')[1],
map['on_delete'] == 'cascade' ? ForeignKeyAction.cascade : ForeignKeyAction.setNull,
map['on_update'] == 'cascade' ? ForeignKeyAction.cascade : ForeignKeyAction.setNull,
);
case 'unique':
return UniqueConstraint(null, map['column']! as String);
default:
throw Exception("No table constraint for type ${map["type"]}");
}
}