Show:

Base model that supports projections and copying.

Methods

_saveBelongsToObserver

(
  • sender
  • key
)
private

Save canonical state for belongsTo relationships.

Parameters:

_saveCanonicalBelongsTo

() private

Set each belongsTo relationship, observer, that save canonical state.

beforeSave

(
  • [options]
)
Promise

Triggers model's 'preSave' event & allows to execute some additional async logic before model will be saved.

Parameters:

  • [options] Object optional

    Method options

    • [softSave= false] Boolean optional

      Flag: indicates whether following 'save' will be soft (without sending a request to server) or not

    • [promises] Promise[] optional

      Array to which 'preSave' event handlers could add some asynchronous operations promises

Returns:

Promise:

A promise that will be resolved after all 'preSave' event handlers promises will be resolved

changedBelongsTo

() Object

Return object with changes.

Object will have structure:

  • key - is name relationships that has changed
    • array - include two items, old value, with index 0, and new value, with index 1.

Returns:

Object:

Object with changes, empty object if no change.

Example:

{
                      key: [oldValue, newValue],
                    }
                    

changedHasMany

() Object

Return object with changes.

Object will have structure:

  • key - is name relationships that has changed
    • array - include two array, array with index 0 this old values, array with index 1 this new values.

Returns:

Object:

Object with changes, empty object if no change.

Example:

{
                      key: [
                        [oldValues],
                        [newValues],
                      ],
                    }
                    

defineIdType

(
  • newIdType
)
public static

Defines idType for specified model type.

Parameters:

  • newIdType String

    Model id type.

defineProjection

(
  • projectionName
  • modelName
  • attributes
)
Object public static

Defines projection for specified model type.

Parameters:

  • projectionName String

    Projection name, eg 'EmployeeE'.

  • modelName String

    The name of the model type.

  • attributes Object

    Projection attributes.

Returns:

Object:

Created projection.

didCreate

()

Fired when the record is created. More info.

didLoad

()

Fired when the record is loaded from the server. More info.

didUpdate

()

Fired when the record is updated. More info.

hasChangedBelongsTo

() Boolean

Сheck whether there is a changed belongsTo relationships.

Returns:

Boolean:

Returns true if belongsTo relationships have changed, else false.

hasChangedHasMany

() Boolean

Сheck whether there is a changed hasMany relationships.

Returns:

Boolean:

Returns true if hasMany relationships are changed.

makeDirty

()

Turns model into 'updated.uncommitted' state.

Transition into the updated.uncommitted state if the model in the saved state (no local changes). Alternative: this.get('currentState').becomeDirty();

preSaveSetId

()

Sets Id on preSave.

rollbackAll

()

Rollback all changes.

rollbackBelongsTo

(
  • [forOnlyKey]
)

Rollback changes for belongsTo relationships.

Parameters:

  • [forOnlyKey] String optional

    If specified, it is rollback invoked for relationship with this key.

rollbackHasMany

(
  • [forOnlyKey]
)

Rollback changes for hasMany relationships.

Parameters:

  • [forOnlyKey] String optional

    If specified, it is rollback invoked for relationship with this key.

rollbackRelationships

()

Rollback changes for all relationships.

save

(
  • [options]
)
Promise

Triggers 'preSave' event, and finally saves model.

Parameters:

  • [options] Object optional

    Method options

    • [softSave= false] Boolean optional

      Flag: indicates whether following 'save' will be soft (without sending a request to server) or not

Returns:

Promise:

A promise that will be resolved after model will be successfully saved

Properties

_canonicalBelongsTo

Object private

Stored canonical belongsTo relationships.

_parentModelName

String private static

Parent model type name.

Default: null

isCreatedDuringSyncUp

Boolean

Flag that indicates model is created during sync up process.

Default: false

isCreatedDuringSyncUp

Boolean

Flag that indicates model is updated last time during sync up process.

Default: false

isCreatedDuringSyncUp

Boolean

Flag that indicates model is destroyed during sync up process.

Default: false

isSyncingUp

Boolean

Flag that indicates sync up process of model is processing.

Default: false

isType

String

Flag that indicates model id type.

Default: 'guid'

namespace

String static

The namespace in which this model is defined.

Default: ''

projections

Ember.Object public static

Defined projections for current model type.

Default: null