How can we improve Breeze.js?

Expose a method on the EntityManager to "unwrap" an entity instance (toJS).

There are a few use cases where an entity instance needs to be sent to the server to an MVC API controller (for example for async server side validation); to do this, it is necessary to obtain an unwrapped version of the instance (plain JSON) that contains no internal properties such as entityAspect and uses properties instead of observables (ko.mapping.toJS is not suitable because of the former). Also, because the client configuration allows for a different naming convention, the method should be able to translate the names back to the naming convention originally used by the server.

Such a method already exists inside the EntityManager, is called "unwrapEntities" although it is private; so the suggestion is only moving it to the public interface of the EntityManager.

More details on this suggestion can be found in http://stackoverflow.com/questions/16202485/breeze-js-how-to-transform-a-breeze-entity-to-a-plain-json-object.

139 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Tona DiazTona Diaz shared this idea  ·   ·  Admin →

    5 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Claus ConradClaus Conrad commented  · 

        This would be VERY nice. As a workaround I currently requery (.fromEntities) and .select() the desired attributes, but an .unwrap method would be cleaner

      • HeikoHeiko commented  · 

        Just to bring this back to memory. Unwrapped entities is a MUST if handling with all things non-breeze and non-knockout like sending to another webservice or just fill some third-party widget with data.

      • gopherukgopheruk commented  · 

        +1. Currently trying to unwrap some entities to raw JSON in order to do a diff on them via library such as JsonDiffPatch

      • Steve BrownSteve Brown commented  · 

        This is something we could really use. We want to be able to convert our Breeze client Entities to plain JSON and send them down the wire to other non-Breeze WebAPI service controllers. Problem we have encountered is that when using ko.toJS() it blows up with a circular reference error.

      Feedback and Knowledge Base