bin/ampersand-jsonapi-model.js
function parse(data) {

    // If this comes from a collection, there won't be a data property.
    // If it comes from querying the model API directly, it will.
    if (!data || !data.data && !data.id) {
      return {};
    }

    var model = data.data ? data.data : data;

    /** The attributes on the model. */
    var attributes = model.attributes;

    // The ID is outside of the other attributes.
    attributes.id = model.id;
    attributes.type = model.type;

    // We have to remember this so that we can parse the children
    this._attrs = attributes;

    return attributes;
  }
function parse(data) {

    // If this comes from a collection, there won't be a data property.
    // If it comes from querying the model API directly, it will.
    if (!data || !data.data && !data.id) {
      return {};
    }

    var model = data.data ? data.data : data;

    /** The attributes on the model. */
    var attributes = model.attributes;

    // The ID is outside of the other attributes.
    attributes.id = model.id;
    attributes.type = model.type;

    // We have to remember this so that we can parse the children
    this._attrs = attributes;

    return attributes;
  }
function parse ( data ) { // If this comes from a collection, there won't be a data property. // If it comes from querying the model API directly, it will. if ( ! data || ! data . data && ! data . id ) { return { } ; } var model = data . data ? data . data : data ; /** The attributes on the model. */ var attributes = model . attributes ; // The ID is outside of the other attributes. attributes . id = model . id ; attributes . type = model . type ; // We have to remember this so that we can parse the children this . _attrs = attributes ; return attributes ; }
Parses the server response into a format which Ampersand Models
expect. Called when collection is initialized.
@method parse
@memberof JSONAPIModel
@instance
@override
@param {Object} data - The data received from the server.
@returns {Object} The transformed model.
Parses the server response into a format which Ampersand Models expect . Called when collection is initialized .