My feedback

  1. 214 votes
    Sign in
    Sign in with: Facebook Google
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    14 comments  ·  1. BreezeJS Feature Suggestions  ·  Flag idea as inappropriate…  ·  Admin →
    An error occurred while saving the comment
    Alex commented  · 

    Hello John,

    I agree with you that create one http method for all CRUD operations for web api is simplest way. But it's not correct in case if developer want to create real RESTfull service which is shared for some audience and used in own app.

    About transactions.. I think that creating and commiting of transaction it's not RESTfull approach. So I'll agree with persons from this discussion that one RESTfull request is corresponding to one transaction.
    "In your request, you seem to be saying that the developer could use a REST API for saving a single entity, and a batch API (WebApi or OData batch) for saving all changes at once. This seems like the road to partial saves and all their problems." - not quite.

    Imagine that our domain model consists from three entities: Category, Product, Price. Category can have many products. Product have Category and one or more Prices.

    Let's imagine that we've created API for own usage and for some community:

    GET: http://someurl/api/categories/1
    POST: http://someurl/api/categories
    paramns: {name: 'category'}
    PUT: http://someurl/api/categories/1

    GET: http://someurl/api/products/1
    params: {name: 'product', prices:[{id:1, value: 100}, {id: 2, value: 200}]}

    Now we want create own app on base of this api and using breezejs. For now it's impossible.. For now breezejs will send every request as post method.

    Let's look at way that I'm suggesting.

    1) a) User filled form for creating of category and clicked save. Breeze.js should check how many entities in unchanged state. If only one entity is in affected then breezejs have to send request with with post http method and data corresponding only to entity(without entity aspect or any additional info). Identity information should be updated from data which will be returned from request.
    b) User want delete category. Breeze check the same condition and send request with DELETE http method. The same for update(put method)
    2) User filled form for creating of products. Added two price entities to product entity in this form. Business rule is that manipulation with product and prices is one business transaction. Breezejs start checking count of unchanged entities and will find that there are three entities in 'added' state.
    Breezejs must decide is it batch commit or it's one business transaction. In this case you have to add possibility for developer to mark manipulations with some entities as one business transaction(show somehow for breezejs that manipulations with product and prices is one business transaction with product entity in role of parent)
    In this case breezejs will determine that all affected entities is one business transaction, find root(parent) object and create post data(for ex {name: 'product', prices:[{id:1, value: 100}, {id: 2, value: 200}]}). Then send one request with POST http method for creation. Identity information should be updated from data which will be returned from request.
    The same logic for update/delete but with different params and http methods
    3) Breezejs found that all affected entities are different business transaction. In this case breezejs can use existing functionality for batch saving in web api or odata depending on saveoptions.
    In this situation we must add to existing API(for customers or products) supporting for one additional http method for batch saving. I think batch save will be used only in synchronizing of offline and online storages or in difficult requirements for app.

    So if breezejs will be implemented in that way then developers will be able to create real RESTfull api, web app based on created api with breezejs and breezejs will use batch saving if it has need. And it's very neccesary to mark that developer have just to mark somehow that some manipulations with multiple entities should be handled as one transaction(it should be implemented) and breezejs will resolve other difficult situations.

    I'm not arguing that it's not simple logic but if breezejs will support this then I think you won't have competitors :).

    Alex shared this idea  · 
    An error occurred while saving the comment

Feedback and Knowledge Base