It's the same as I would do saving to a regular FeatureService.I have a module that is used to perform all my saves/syncsI put together a more comprehensive example of how I use perform saves/updates.
// using the historyutil.js module I posted earlier
var Service = declare([], {
constructor: function(options) {
this.options = options;
this.map = this.options.map;
// the options will have a URL to the
// non-spatial table in my FeatureService
// for recording the history of my edits
this.editHistory = new HisotryUtil(this.options);
// this is the actual layer with spatial features that
// I will edit.
this.editLayer = this.map.getLayer('defectsLayer');
},
save: function(name, adds, updates) {
var deferred = new Deferred();
var self = this;
// first edit my spatial layer
// NOTE - Deletes not allowed in app, but you could track that if
// needed.
this.editLayer.applyEdits(adds, updates, null, function (results) {
// when spatial table successfully edited, send same
// edits to history table using the HistoryUtil
// module in previous post.
self.editHistory.save(adds, filterUpdate(updates));
self.editLayer.refresh(); // quick refresh
// I don't to see if
// history update finished because I don't care.
// History is a backend thing, not app related.
// In production I would check if this failed and
// log it somewhere else.
// Now I can resolve my results.
deferred.resolve(results);
}, function (error) {
deferred.reject(error);
});
return deferred.promise;
},
});
// This function finds out if two field
// values are identical
function statsMatch(obj, field1, field2) {
return obj[field1] === obj[field2];
}
// If I'm doing an update of data, I just track status changes.
// So I filter out any features where the status did NOT change.
function filterUpdate(items) {
return arrayUtil.filter(items, function(item) {
// helper function to see if the status changed
return !statsMatch(item.attributes, 'PreviousStatus', 'DefectStatus');
});
}
return Service;