问题
I tried to use the named saves as below and as explained in the release notes here, but it dosen't work and returns:
Uncaught Error: The 'entities' parameter is optional or it must be an array where each element must be an entity => breeze.debug.js:724
proto.check => breeze.debug.js:724
proto.saveChanges => breeze.debug.js:11150
sendEmail
The function is:
var sendEmail = function () {
var option = new breeze.SaveOptions({ resourceName: 'sendMail'})
return manager.saveChanges({ saveOptions: option })
.then(saveSucceeded)
.fail(saveFailed);
function saveSucceeded(saveResult) {
log('La email è stata invata.', saveResult, true);
}
function saveFailed(error) {
var msg = 'Invio della email è fallito: ' + getErrorMessages(error);
logError(msg, error);
error.message = msg;
throw error;
}
};
Any help appretiated!
回答1:
The writeup in the release notes has the wrong syntax. I will have it fixed.
The first arg to EntityManager.saveChanges is always a list of entities, or it can be null to indicate all entities. The 2nd arg is an optional SaveOptions instance. See here. So your expression should be
var option = new breeze.SaveOptions({ resourceName: 'sendMail'})
return manager.saveChanges(null, option)
来源:https://stackoverflow.com/questions/16421404/breeze-named-saves-do-not-work-as-expected