[Persistence] Only auto-persist previously saved domain objects

This commit is contained in:
Victor Woeltjen 2016-04-29 11:31:36 -07:00
parent 6418b0c634
commit b0cbb5a2b4
2 changed files with 12 additions and 1 deletions

View File

@ -202,6 +202,15 @@ define(
return this.identifierService.parse(id).getSpace();
};
/**
* Check if this domain object has been persisted at some
* point.
* @returns {boolean} true if the object has been persisted
*/
PersistenceCapability.prototype.persisted = function () {
return this.domainObject.getModel().persisted !== undefined;
};
return PersistenceCapability;
}
);

View File

@ -34,7 +34,9 @@ define([], function () {
var mutationTopic = topic('mutation');
mutationTopic.listen(function (domainObject) {
var persistence = domainObject.getCapability('persistence');
persistence.persist();
if (persistence.persisted()) {
persistence.persist();
}
});
}