I'm currently trying to synchronize huge data from ODATA 4 webservice into an ionic SQLite database.
The entity I'm trying to fetch contains like 100k rows.
What is the best way to batch it ?
Actually, I'm doing the following steps :
private top: number = 800;
private skip: number = 0;
synchronize() {
let service = this.factory.entitySet<Entity>("Entity");
let serviceEntities = ireService.entities();
return serviceEntities
.query((q) => {
q.top(this.top);
q.skip(this.skip);
})
.fetch()
.subscribe(({ entities }) => {
if (entities!.length === this.top) {
this.skip += this.top;
this.synchronize();
}
});
}
It's working fine but when I call synchronize() I would like to be able to wait the end of the excution of the whole batch but I don't really know how do it. Should I return something ?