Closed kakugiki closed 6 years ago
That means that indexeddb data in the developer tools are not latest, it mght be old. So clicking on refresh icon will fetch latest data and the warning about stale data will be gone.
The developer doesnot refresh data automatically, you need to manually refresh it.
No, that's is obvious. I meant to say is the view is stale. I updated the idb store with an API and want to see the update from the web page, but the select only gave me the old record.
ok so you are saying that - you update the record then select the record but you are getting old record in select right ?
Yup, that's it. Any idea?
Are you using transaction api ?
It's .net core api using Dapper.SqlMapper. Not sure does it matter since I can tell the idb is indeed updated when I refresh it from the Developer tools.
No it does not matter actually whatever backend technology we are using. I am asking about jsstore transaction api.
I believe, then your query is something like this -
connection.update({
})
connection.select({
})
Let me know. If you are using this query make sure you are using same where qry in select as in update. For confirming this do one thing - keep where query in a variable and then use that in both api.
Also turn on jsstore log and see in console how the query is being executed. For log api, check here - http://jsstore.net/tutorial/helpers/
OK, I guess that's the reason. I use set instead of your transaction api to update the record. It's easier to update this way: set(caseId, response[0]), where caseId is the primary key. It certainly update the record successfully as you can see the newly updated result by refresh from the Developer tools. I need to run the search again to bring the update to the web page. You can close this one then, if that's the case. Thanks for your help anyway.
This issue may not be directly related to JsStore. I figured it out by updating the idb and angular scope at the same time instead of only updating the idb and then retrieve the record from idb. I'll close this thread. Thank you for time!
Are you using get, set api ? Let me know.
I actually use idbKeyval.set(caseId, response[0]);
and what is idbKeyVal ?
ok I see, its another library. Sorry but I can't say anything about it. But my guess is - this issue happens when you are executing multiple query in a same transaction.
Anyway I would like you to know - jsstore also have "get", "set", api where you can store data in the form of key and value format. Here is the link - http://jsstore.net/tutorial/helpers/
Ok, I'll give it a try. I used that library first before I found yours. Thank you for your time.
should I use jsstore's set the same way as idbKeyval.set(caseId, response[0])? I tried connection.set(caseId, response[0]), but couldn't update the idb. caseId is the primary key. BTW, it should be 'value set' not 'value setted'.
I tried connection.set(caseId, response[0]), but couldn't update the idb -
I think due to the multiple library , there may be confusion, so please use one library.
BTW, it should be 'value set' not 'value setted'. -
Sorry i am not able to understand what do you mean by this. Could you please explain more ?
I tried connection.set(caseId, response[0]), but couldn't update the idb -
This may not be an issue specific to JsStore, but I would like to ask your input. I use JsStore to store a query result and later update one of the records. When I use connection.select({ ... }) to retrieve the data, it's not updated. I need to search again to get the update. You call tell the idb was udpated, as it says "Data may be stale".
Is there a way to refresh idb before select, or something like that? Thank you very much for your time.