Sunday, January 27, 2019

Re: elemental2 indexeddb example?

Thanks, I did make some progress.   I dug around a little in the javadoc and found the IndexedDbGlobal, which I was able to use to create a new database.


elemental2.indexeddb.IDBFactory indexedDB = elemental2.indexeddb.IndexedDbGlobal.indexedDB;

elemental2.indexeddb.IDBOpenDBRequest openDBRequest = indexedDB.open("mydbtest", 1.0);


So far so good.


With a open database call, I get a returned object of elemental2.indexeddb.IDBOpenDBRequest (https://static.javadoc.io/com.google.elemental2/elemental2-indexeddb/1.0.0-RC1/elemental2/indexeddb/IDBOpenDBRequest.html)



In the google documentation that I have found that describes the indexedDB open operation, https://developers.google.com/web/ilt/pwa/working-with-indexeddb#opening_a_database


They provide the following code:

  var dbPromise = idb.open('test-db2', 1, function(upgradeDb) {
    console
.log('making a new object store');
   
if (!upgradeDb.objectStoreNames.contains('firstOS')) {
      upgradeDb
.createObjectStore('firstOS');
   
}
 
});

I want to register a function to execute when the database is upgraded.  I see there is a openDBRequest.onupgradeneeded(), but I just can't the syntax right.


elemental2.indexeddb.IDBFactory indexedDB = elemental2.indexeddb.IndexedDbGlobal.indexedDB;

elemental2.indexeddb.IDBOpenDBRequest openDBRequest = indexedDB.open("mydbtest", 1.0);


//how to i call a function for upgrade?  I want to create some object stores.

openDBRequest. onupgradeneeded = doUpgrade();

Thanks for your help.



On Sunday, January 27, 2019 at 5:48:37 AM UTC-5, Thomas Broyer wrote:
Elemental2 API map directly to the native browser APIs, so you'll start with IndexedDBGlobal.indexedDB and walk your way almost exactly like you'd do in JS.
Javadoc can be found here fwiw: https://javadoc.io/doc/com.google.elemental2/elemental2-indexeddb/1.0.0-RC1

On Sunday, January 27, 2019 at 5:57:44 AM UTC+1, rhodebump wrote:

I am interested in using indexeddb from within GWT.  I found the following library that indicates that it provides indexeddb support https://github.com/google/elemental2


Does anyone have an example of opening a database? 


Thanks,

Phillip



--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment