Question

I'm trying to get information from an indexedDB, and I want to get just the object from one store by key, and not all the objects from the database. In some examples of javascript and IndexedDB they use the method get() to get the value depending of the key. In DART there is not such method but there is getObject().

How do I get the value of the object when using getObject(key)?

Thanks a lot in advance!

Was it helpful?

Solution

Actually it has getObject(key) method, take a look here https://api.dartlang.org/apidocs/channels/stable/#dart-dom-indexed_db.ObjectStore@id_getObject

The other way for fetching data is Cursor. Here is a good tutorial https://www.dartlang.org/docs/tutorials/indexeddb/#getting-data

OTHER TIPS

So all needed to do was to create a callback. This is how I got the objects value:

var id = "example";
var trans = _db.transaction('myDB', 'readwrite');
var store = trans.objectStore(_TODOS_STORE);

// Get the value from one object ! and render it 

var request = store.getObject(id).then((val){functionFor(val);});

Futures need from callbacks to be able to use their values.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top