import 'package:realm/realm.dart';
part 'schemas.g.dart';
@RealmModel()
class _ItemCategory {
@MapTo('_id')
@PrimaryKey()
late ObjectId id;
late String name;
late String description;
late bool isActive;
@Backlink(#categories)
late _ItemType? type;
late List<_Item> categories;
}
@RealmModel()
class _ItemType {
@MapTo('_id')
@PrimaryKey()
late ObjectId id;
late String name;
late String description;
late bool isConsumable;
late List<_ItemCategory> categories;
late bool isActive;
}
@RealmModel()
class _Item {
@MapTo('_id')
@PrimaryKey()
late ObjectId id;
late String name;
late String description;
late bool isActive;
@Backlink(#items)
late _ItemCategory? type;
}
Requirements
- Item Category must belong to one Type of ItemType
- ItemType can link to a numbers of ItemCategory
- Item type must belong to one or more CategoryType
- CategoryType link to a number of Type
Can you please modify my code to meet my requirements