我的应用程序有用于所有实体(服务器端)的字符串ID,我希望从蜂巢迁移到Isar,所以我正在读取会计准则专家组文件,发现它不支持String ID (只有int),是的,我知道我可以创建这样一个类:
@Collection()
class Student {
int? id;
@Index(unique: true)
String? myServerId;
late String name;
final teacher = IsarLink<Teacher>();
}当我从服务器获取数据(JSON)时,id字段(Isar的管理器)不是来自服务器,所以我保存这个记录--本地Isar将创建ID OK,下次需要通过myServerId检查从服务器获得相同的记录时,如果存在由IsarE 215创建的id更新,我如何管理它与teacher这样的实体文件?需要检查每个实体的孩子还是有更好的方法?提前感谢
发布于 2022-10-13 00:05:48
将replace设置为true in @Index of myServerId,如下所示:
@Collection()
class Student {
int? id;
@Index(unique: true , replace:true)
String? myServerId;
late String name;
final teacher = IsarLink<Teacher>();
}看看这个Isar替换索引Doc。
https://stackoverflow.com/questions/71959600
复制相似问题