Flutter Isar String ID

Viewed 455

My app have String ID for all entities (Server side) I want migrate from Hive to Isar so I was reading the Isar documentation and find out it doesn't support String ID (only int), Yes I know that I can create a Class like this:

@Collection()
class Student {
  int? id;
  @Index(unique: true)
  String? myServerId;
  late String name;
  final teacher = IsarLink<Teacher>();
}

When I fetch data (JSON) from server the id field (manager for Isar) don't came from server, so I save this record local Isar will create the ID OK, next time I get the same record from server is needed check via myServerId and if exist just update with id created by Isar its easy, how I can manager its with all entities filds like teacher? Need check every entities child or have a better way? Thanks in advance

0 Answers
Related