From e95c1122bcd3641ae0044553220d8c7d90a36455 Mon Sep 17 00:00:00 2001 From: Edward Lee Date: Mon, 31 Aug 2009 18:30:44 -0700 Subject: [PATCH] Switch to 0.5 server API for deleting multiple ids from a collection. --- services/sync/modules/base_records/collection.js | 10 ++++++++++ services/sync/modules/engines.js | 9 +-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/services/sync/modules/base_records/collection.js b/services/sync/modules/base_records/collection.js index 57d3a286794f..9a5bcf4652a6 100644 --- a/services/sync/modules/base_records/collection.js +++ b/services/sync/modules/base_records/collection.js @@ -61,6 +61,7 @@ Collection.prototype = { this._init(uri); this.pushFilter(new JsonFilter()); this._full = true; + this._ids = null; this._older = 0; this._newer = 0; this._data = []; @@ -80,6 +81,8 @@ Collection.prototype = { args.push('full=1'); if (this.sort) args.push('sort=' + this.sort); + if (this.ids != null) + args.push("ids=" + this.ids); this.uri.query = (args.length > 0)? '?' + args.join('&') : ''; }, @@ -91,6 +94,13 @@ Collection.prototype = { this._rebuildURL(); }, + // Apply the action to a certain set of ids + get ids() this._ids, + set ids(value) { + this._ids = value; + this._rebuildURL(); + }, + // get only items modified before some date get older() { return this._older; }, set older(value) { diff --git a/services/sync/modules/engines.js b/services/sync/modules/engines.js index 34be75f27f8d..eaf53fb9e8dc 100644 --- a/services/sync/modules/engines.js +++ b/services/sync/modules/engines.js @@ -519,15 +519,8 @@ SyncEngine.prototype = { // Remove the key for future uses delete this._delete[key]; - // Specially handle ids deletion until we have collection?ids=,,, - if (key == "ids") { - for each (let id in val) - new Resource(this.engineURL + id).delete(); - continue; - } - // Send a delete for the property - this._log.info("Sending delete for " + key + ": " + val); + this._log.debug("Sending delete for " + key + ": " + val); let coll = new Collection(this.engineURL, this._recordObj); coll[key] = val; coll.delete();