I have been trying to erase all document from collection and memory before adding new one. I tried it by following methods
1.
WL.JSONStore.get("users").findAll().then(function (arrayResults){
var options={push:true};
if(arrayResults.length>0){
for(var i=1;i<=arrayResults.length;i++){
WL.JSONStore.get("users").remove(i,options);
}
}
});
2.
WL.JSONStore.get("users").findAll().then(function (arrayResults){
var options={};
if(arrayResults.length>0){
for(var i=1;i<=arrayResults.length;i++){
WL.JSONStore.get("users").erase(i,options);
}
}
});
But didn't get success. Its showing all documents by doing findAll
You can use the removeCollection API call to remove all docs in a collection, you will have to re-init the collection if you want to use it again.
Alternatively, try following this example: