Comparing version 1.0.1 to 1.0.2
/// <reference path="../../src/Dexie.js" /> | ||
/* | ||
* Disclaimber: This addon is in alpha status meaning that | ||
* its API and behavior may change. | ||
*/ | ||
(function (window, publish, isBrowser, undefined) { | ||
"use strict" | ||
"use strict"; | ||
@@ -6,0 +11,0 @@ /** class DatabaseChange |
/// <reference path="../../../src/Dexie.js" /> | ||
/// <reference path="../Dexie.Observable/Dexie.Observable.js" /> | ||
/// <reference path="Dexie.Syncable.SyncProtocolAPI.js" /> | ||
/* | ||
* Disclaimber: This addon is in alpha status meaning that | ||
* its API and behavior may change. | ||
*/ | ||
(function (window, publish, isBrowser, undefined) { | ||
@@ -156,2 +161,39 @@ | ||
} | ||
db.syncable.delete = function (url) { | ||
// Notice: Caller should call db.syncable.disconnect(url) and wait for it to finish before calling db.syncable.delete(url) | ||
// Surround with a readwrite-transaction | ||
return db.transaction('rw', db._syncNodes, db._changes, db._uncommittedChanges, function() { | ||
// Find the node | ||
db._syncNodes.where("url").equals(url).first(function(node) { | ||
// If not found, resolve here (nothing deleted), else continue the promise chain and | ||
// delete the node and all that refers to it... | ||
if (!node) { | ||
return; | ||
} else { | ||
var nodeId = node.id; | ||
// Delete the node | ||
return db._syncNodes.delete(nodeId).then(function() { | ||
// When this node is gone, let's clear the _changes table by | ||
// from all revisions older than the oldest node. | ||
// First check which is the currenly oldest node, now when we have deleted | ||
// the given node: | ||
return db._syncNodes.orderBy("myRevision").first(); | ||
}).then(function(oldestNode) { | ||
// Delete all changes older than revision of oldest node: | ||
return db._changes.where("rev").below(oldestNode.myRevision).delete(); | ||
}).then(function() { | ||
// Also don't forget to delete all uncommittedChanges for the deleted node: | ||
return db._uncommittedChanges.where('node').equals(nodeId).delete(); | ||
}); | ||
} | ||
}); | ||
}); | ||
}; | ||
db.syncable.unsyncedChanges = function (url) { | ||
return db._syncNodes.where("url").equals(url).first(function (node) { | ||
return db._changes.where('rev').above(node.myRevision).toArray(); | ||
}); | ||
}; | ||
@@ -158,0 +200,0 @@ function connect (protocolInstance, protocolName, url, options, dbAliveID) { |
@@ -22,3 +22,3 @@ { | ||
"**/.*", | ||
"addons", | ||
"addons/*/test", | ||
"test", | ||
@@ -25,0 +25,0 @@ "samples", |
{ | ||
"name": "dexie", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Minimalistic IndexedDB API with bullet proof transactions", | ||
@@ -5,0 +5,0 @@ "main": "src/Dexie.js", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
321001
5310
0