0
votes

I have the following module (pseudo code below) which saves data back to the server using Breeze.

datacontext{
    ...
    function saveChanges() {
        if (manager.hasChanges()) {
            return manager.saveChanges()
                   .then(saveSucceeded)
                   .fail(saveFailed);
        }
        return Q.resolve();

        function saveSucceeded(data) {
        }
        function saveFailed(data) {
        }
    }
    ...
}

I am capturing the changes that have been saved for some further processing:

datacontext.saveChanges().then(processChanges)

Is it possible to get which properties of a given entity have changed after a save?

1

1 Answers

1
votes

The changes to an entity will have already been changed on the client before you call the save; the save just commits these changes to the server.

However, you can capture the list of changed properties ( and their original values) for each entity BEFORE you call save and use this list if the save completes successfully. Take a look at the 'originalValues' section of this page

http://www.breezejs.com/documentation/inside-entity

function getOriginalValuesPropertyNames(entity) {
    var names = [];
    for (var name in entity.entityAspect.originalValues) { names.push(name); }
    return names;
}