backbone-indexeddb
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -271,3 +271,3 @@ (function () { /*global _: false, Backbone: false */ | ||
}; | ||
writeRequest.onsuccess = function (e) { | ||
writeTransaction.oncomplete = function (e) { | ||
options.success(json); | ||
@@ -296,3 +296,3 @@ }; | ||
}; | ||
writeRequest.onsuccess = function (e) { | ||
writeTransaction.oncomplete = function (e) { | ||
options.success(json); | ||
@@ -310,3 +310,2 @@ }; | ||
var getRequest = null; | ||
@@ -349,3 +348,4 @@ if (json.id) { | ||
var deleteRequest = store.delete(json.id); | ||
deleteRequest.onsuccess = function (event) { | ||
deleteTransaction.oncomplete = function (event) { | ||
options.success(null); | ||
@@ -405,6 +405,6 @@ }; | ||
// Looks like we want the DESC order | ||
readCursor = index.openCursor(bounds, window.IDBCursor.PREV); | ||
readCursor = index.openCursor(bounds, window.IDBCursor.PREV || "prev"); | ||
} else { | ||
// We want ASC order | ||
readCursor = index.openCursor(bounds, window.IDBCursor.NEXT); | ||
readCursor = index.openCursor(bounds, window.IDBCursor.NEXT || "next"); | ||
} | ||
@@ -424,5 +424,5 @@ } else if (options.conditions[index.keyPath] != undefined) { | ||
if (options.range[0] > options.range[1]) { | ||
readCursor = store.openCursor(bounds, window.IDBCursor.PREV); | ||
readCursor = store.openCursor(bounds, window.IDBCursor.PREV || "prev"); | ||
} else { | ||
readCursor = store.openCursor(bounds, window.IDBCursor.NEXT); | ||
readCursor = store.openCursor(bounds, window.IDBCursor.NEXT || "next"); | ||
} | ||
@@ -558,2 +558,30 @@ } else { | ||
var promise; | ||
var noop = function() {}; | ||
if ($ && $.Deferred) { | ||
var dfd = $.Deferred(); | ||
var resolve = dfd.resolve; | ||
var reject = dfd.reject; | ||
promise = dfd.promise(); | ||
} else { | ||
var resolve = noop; | ||
var reject = noop; | ||
} | ||
var success = options.success; | ||
options.success = function(resp) { | ||
resolve(); | ||
if (success) success(resp, options); | ||
object.trigger('sync', object, resp, options); | ||
}; | ||
var error = options.error; | ||
options.error = function(resp) { | ||
reject(); | ||
if (error) error(resp, options); | ||
object.trigger('error', object, resp, options); | ||
}; | ||
var next = function(){ | ||
@@ -565,10 +593,9 @@ Databases[schema.id].execute([method, object, options]); | ||
Databases[schema.id] = new ExecutionQueue(schema,next,schema.nolog); | ||
}else | ||
{ | ||
} else { | ||
next(); | ||
} | ||
return promise; | ||
}; | ||
}; | ||
if(typeof exports == 'undefined'){ | ||
@@ -575,0 +602,0 @@ Backbone.ajaxSync = Backbone.sync; |
@@ -5,3 +5,3 @@ { | ||
"description": "An backbone adapter for indexeddb. Useless for most people untile indexeddb is ported to the browser", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
Sorry, the diff of this file is not supported yet
262455
3015