【发布时间】:2019-09-02 19:31:44
【问题描述】:
这里我一一存储了值。 API 有 100 万条数据。响应时间为 3 秒存储缓存需要很多时间。
如何像选择插入查询一样添加一次所有数据?
storeDefCatMaster(String url,String token) async {
final response = await http.get(
'${url}/v1.0/DefCatMaster',
headers: {'Authorization': 'Bearer ${token}'},
);
final jsonResponse = json.decode(response.body);
DefCatMaster model = DefCatMaster.fromJson(jsonResponse);
int length = model.data.length;
for(int i=0; i<length; i++) {
var data = DataDefCatMaster(
deF_CAT_ID: model.data[i].deF_CAT_ID,
description: model.data[i].description,
in_use: model.data[i].in_use,
sortOrder: model.data[i].sortOrder
);
await helper.insert(data);
}
}
【问题讨论】:
-
我已经完成了这部分。我的问题是长时间存储数据时要存储
-
然后存储 sharedpreference 或 sqlite
标签: sqlite dart flutter async-await sqflite