To have the possibility to connect a TWebIndexedDbConnection to TWebIndexedDbClientDataset. The TWebIndexedDbConnection could load through the uri a json and the feed the dataset. Of course, it is only for retrieving data. Not difficult to write a procedure to feed a TWebIndexedDbClientDataset from json, but...
Do I understand correct that you want to load the IndexedDB automatically from JSON data fetched from an URL?
If so, that is indeed a valuable idea. We'll discuss & consider this here.
Correct. That's the idea!
I now use TWebHttpRequest to catch the json and then put record for record in the database using the following code. However, when I close the application immediately after the last record is inserted (according to what I see in the console) and restart the application it turns out the only a small number of records are actually stored in the IndexDB database. The question is if there is an event that can inform that all data is actually stored in the database.
JS := TJSON.Create;
ja := TJSONArray(JS.Parse(AResponse));
for i := 0 to ja.Count - 1 do
begin
jo := TJSONObject(ja.Items[i]);
speciesname := jo.GetJSONValue('soortnaam');
speciesnr := jo.GetJSONValue('soortnr');
Console.Log(speciesname);
WebIndexedDbCdsSpecies.Insert;
WebIndexedDbCdsSpecies.FieldByName('speciesnr').AsString := speciesnr;
WebIndexedDbCdsSpecies.FieldByName('speciesname').AsString := speciesname;
WebIndexedDbCdsSpecies.Post;
end;