CompatModel
The idea of CompatCollection
and CompatModel
is to make migration from mobx-collection-store
and mobx-jsonapi-store
simpler.
Note: They should be used for migration only, and once you switch to datx
, you should refactor your collections and models to use Model
or PureModel
. The usage of this class will emit deprecation warnings during development to make migration easier.
CompatModel
enhances the PureModel
with the following properties and methods:
static idAttribute
- string, default is"id"
- the attribute that will be used as idstatic typeAttribute
- string, default is"__type__"
- the attribute that will be used as typestatic refs
- Dictionary of the references. The reference type will always beTO_ONE_OR_MANY
. Equivalent toprop.toOneOrMany
.static defaults
- Dictionary of default property values. Used also to set observable properties. Equivalent toprop
orprop.defaultValue
.getRecordId
- Returns the model ID. Equivalent togetModelId
.getRecordType
- Returns the model type. Equivalent togetModelType
.assign
- Assign a value to a property. Equivalent toassignModel
.assignRef
- Assign a new reference to the model. Equivalent toinitModelRef
with theTO_ONE_OR_MANY
reference type.update
- Update the model with the given key/value object. Equivalent toupdateModel
.static
- Getter for the static model class. Mostly for internal use.toJS
- Get the immutable model snapshot. Equivalent tomodelToJSON
.snapshot
- Getter for the immutable model snapshot. Equivalent tomodelToJSON
.