mobx-decorated-models
Advanced tools
Comparing version 0.8.2 to 0.8.3
@@ -313,7 +313,11 @@ (function (global, factory) { | ||
}); | ||
serializr.createModelSchema(model, serializeSchema); | ||
schema.forEach(function (_ref2, name) { | ||
var type = _ref2.type, | ||
options = _ref2.options; | ||
serializr.createModelSchema(model, serializeSchema, function (_ref2) { | ||
var json = _ref2.json; | ||
return new model(json); | ||
}); // eslint-disable-line new-cap | ||
schema.forEach(function (_ref3, name) { | ||
var type = _ref3.type, | ||
options = _ref3.options; | ||
if (Associations[type] || options.model) { | ||
@@ -353,5 +357,5 @@ addReference(model, name, options, Associations[type] || Associations.belongsTo); | ||
function unresolvedAssociations() { | ||
return PendingLookups.map(function (_ref3) { | ||
var model = _ref3.parentModel, | ||
property = _ref3.propName; | ||
return PendingLookups.map(function (_ref4) { | ||
var model = _ref4.parentModel, | ||
property = _ref4.propName; | ||
return { model: model, property: property }; | ||
@@ -358,0 +362,0 @@ }); |
@@ -310,7 +310,11 @@ import { SKIP, createModelSchema, custom, deserialize, getDefaultModelSchema, identifier, list, object, primitive, serialize, update } from 'serializr'; | ||
}); | ||
createModelSchema(model, serializeSchema); | ||
schema.forEach(function (_ref2, name) { | ||
var type = _ref2.type, | ||
options = _ref2.options; | ||
createModelSchema(model, serializeSchema, function (_ref2) { | ||
var json = _ref2.json; | ||
return new model(json); | ||
}); // eslint-disable-line new-cap | ||
schema.forEach(function (_ref3, name) { | ||
var type = _ref3.type, | ||
options = _ref3.options; | ||
if (Associations[type] || options.model) { | ||
@@ -350,5 +354,5 @@ addReference(model, name, options, Associations[type] || Associations.belongsTo); | ||
function unresolvedAssociations() { | ||
return PendingLookups.map(function (_ref3) { | ||
var model = _ref3.parentModel, | ||
property = _ref3.propName; | ||
return PendingLookups.map(function (_ref4) { | ||
var model = _ref4.parentModel, | ||
property = _ref4.propName; | ||
return { model: model, property: property }; | ||
@@ -355,0 +359,0 @@ }); |
@@ -140,3 +140,4 @@ import { | ||
}); | ||
createModelSchema(model, serializeSchema); | ||
createModelSchema(model, serializeSchema, ({ json }) => new model(json)); // eslint-disable-line new-cap | ||
schema.forEach(({ type, options }, name) => { | ||
@@ -143,0 +144,0 @@ if (Associations[type] || options.model) { |
{ | ||
"name": "mobx-decorated-models", | ||
"version": "0.8.2", | ||
"version": "0.8.3", | ||
"description": "Decorators to make using Mobx for model type structures easier", | ||
@@ -44,5 +44,5 @@ "main": "dist/build.full.js", | ||
"rollup-plugin-babel": "^2.7.1", | ||
"serializr": "^1.1" | ||
"serializr": "^1.1.14" | ||
}, | ||
"dependencies": {} | ||
} |
import { findModel } from '../lib/model-lookup'; | ||
import { Container, Box, Ship } from './test-models'; | ||
import { Container, Box, Ship, Registration } from './test-models'; | ||
import { unresolvedAssociations } from '../lib/class-decorator'; | ||
@@ -30,2 +30,8 @@ | ||
it('passes attributes to a model when deserializing a hasMany', () => { | ||
const ship = Ship.deserialize({ homePorts: ['one', 'two', 'three'] }); | ||
expect(ship.homePorts[0]).toBeInstanceOf(Registration); | ||
expect(ship.homePorts[1].id).toEqual('two'); | ||
}); | ||
it('can deserialize arrays', () => { | ||
@@ -32,0 +38,0 @@ const json = [ |
@@ -56,2 +56,3 @@ import { observable, computed } from 'mobx'; | ||
@belongsTo({ inverseOf: 'vessel' }) box; | ||
@hasMany({ model: Registration }) homePorts; | ||
@@ -58,0 +59,0 @@ constructor(attrs) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
283109
1885