I'm using the jQuery-plugin jQuery-indexeddb to deal with an indexedDB.
My current problem is, that I want to add an object to an objectStore, but only if this object is not existing in another certain objectStore.
At the moment I'm using the code which follows, but the problem is that the .add function gives me an exception for every call that the object already exists, which means that the order-object which I'm generating outside of the promise for each pass of the for-loop stays the same.
What can I do to solve
Update
function fillStoreWithJson(data, store) {
var promises = [];
$.each(data,function (index,element) {
store.add(element);
orderIsFinished(element["AUFTRAGNR"]).done(function (result) {
if (result === false) {
var def = new $.Deferred();
store.add(element).done(function (result, event) {
def.resolve(result);
});
promises.push(def);
}
});
});
return $.when.apply(undefined, promises).promise();
And then doing this:
fillStoreWithJson(orderJson, orderObjectStore).done(function() {
showOrderList();
});
doesnt find something in the databse. i think the reason is, that it is executed before the entries are inserted. So i have to wait until all entries are inserted and then call the display-method. i've tried it with the above updated code but it didnt work: could you help me again please. thanks a lot.
– user3507003 Feb 22 '15 at 11:41