问题
It sounds like the SaveChanges of BreezeJS is great for quick demos, but most real life applications need some sort of unit of work, business requirements, and/or sanity checks before actually saving to the data store. Is there a way to integrate BreezeJS with an ajax call that deals with inserting, deleting, and or updating the data rather than using SaveChanges?
回答1:
Breeze allows you to both change the server endpoint for 'SaveChanges' via the SaveOptions.resourceName property. (See the EntityManager.SaveChanges api for more info). You can also intercept the SaveChanges call on the server. ( See Save interception in the Breeze Documentation).
Moreover, there is no requirement that you use the current implementation of the Server side SaveChanges code. As long as you work with the SaveBundle that Breeze sends to the server and return a server side SaveResult, Breeze will work just fine. Admittedly, we don't yet have a great deal of documentation on this process, but the code is open-source and you can certainly see how its done right now.
In a related vein, we are working on an example of using Breeze against a MongoDb running under Node that uses completely different 'SaveBundle' and 'SaveResult' formats. We should be releasing this within the next few weeks.
来源:https://stackoverflow.com/questions/16797084/how-to-call-an-arbitrary-service-for-saving-changes-with-breezejs