How to get an already created JSONStore in Mobilefirst -


i trying create jsonstore in mobilefirst 7.0 hybrid app. issue having able detect jsonstore there on subsequent runs of app. documentation says have have called wl.jsonstore.init(...) before calling wl.jsonstore.get(...).

so question is, on subsequent runs of app (meaning app ran first time , created jsonstore successfully) , new run, proper way check if jsonstore exists?

if have call init again, how do without wiping out there?

i using snippet of code detect...

function checkjsonstore() {  alert("in checkjsonstore");  var collectionname;  try {     // check see if jsonstore exists...     collectionname = wl.jsonstore.get('appstore');  } catch (e) {     // todo: handle exception     alert("checkjsonstore: exception = " + e.message); }  alert("returning checkjsonstore: " + collectionname);  return collectionname; } 

here code create store...it runs successfully.

function initjsonstore() {  console.log("in initjsonstore:");  var collectionname = "appstore";  var data = {  item: 'newinstall',  value: 1 };  var jsonstorecollections = {}; jsonstorecollections[collectionname] = {}; jsonstorecollections[collectionname].searchfields = {item: 'string'};  try {      console.log("destroy collections before start");      wl.jsonstore.destroy().then(function () {         //handle success         console.log("initjsonstore: jsonstore destroy success");     })     .fail(function (error) {         //handle failure         console.log("initjsonstore: jsonstore destroy failure: " + error);     });      console.log("calling wl.jsonstore.init");      wl.jsonstore.init(jsonstorecollections).then(function () {          console.log("initjsonstore: jsonstore init success");          wl.jsonstore.get('appstore').add(data).then(function () {              console.log("initjsonstore: jsonstore add success");          }).fail(function (error) {              console.log("initjsonstore: jsonstore add failure: " + error);         });      }).fail(function (error) {          console.log("initjsonstore: jsonstore init failure");     }); } catch (e) {     // todo: handle exception     //console.log("initjsonstore: exception = " + e.message);     alert("initjsonstore: exception = " + e.message); } console.log("exiting initjsonstore:");  } 

calling .init again not wipe already-created collection. calling .destroy already-created collection destroyed... , on next init (re-)created.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -