rest-client-sdk
Advanced tools
Comparing version 2.0.0-rc.2 to 2.0.0-rc.3
{ | ||
"name": "rest-client-sdk", | ||
"version": "2.0.0-rc.2", | ||
"version": "2.0.0-rc.3", | ||
"description": "Rest Client SDK for API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -37,3 +37,8 @@ # Mapado Rest Client JS SDK [![Build Status](https://travis-ci.org/mapado/rest-client-js-sdk.svg?branch=master)](https://travis-ci.org/mapado/rest-client-js-sdk) [![Greenkeeper badge](https://badges.greenkeeper.io/mapado/rest-client-js-sdk.svg)](https://greenkeeper.io/) | ||
productMetadata.setRelationList([ | ||
new Relation('categoryList', Relation.ONE_TO_MANY), | ||
new Relation( | ||
Relation.ONE_TO_MANY, // type: Relation.ONE_TO_MANY or Relation.MANY_TO_ONE | ||
'categories', // targetMetadataKey: must match the first argument of `ClassMetadata` constructor of the target entity | ||
'category_list', // serializedKey: the key returned from your API | ||
'categoryList', // attributeName: optional, the name in your entity, default to the `serializedKey` attribute | ||
), | ||
]); | ||
@@ -47,3 +52,3 @@ | ||
categoryMetadata.setRelationList([ | ||
new Relation('product', Relation.MANY_TO_ONE), | ||
new Relation(Relation.MANY_TO_ONE, 'product', 'product'), | ||
]); | ||
@@ -50,0 +55,0 @@ |
class Relation { | ||
constructor(type, relationKey, serializedKey /* , targetEntity */) { | ||
constructor(type, targetMetadataKey, serializedKey, attributeName = null) { | ||
this.type = type; | ||
this.targetMetadataKey = targetMetadataKey; | ||
this.serializedKey = serializedKey; | ||
this.relationKey = relationKey; | ||
// this.targetEntity = targetEntity; | ||
this.attributeName = attributeName || this.serializedKey; | ||
} | ||
@@ -8,0 +8,0 @@ |
@@ -172,3 +172,3 @@ import { isImmutable } from 'immutable'; | ||
relationList.forEach((newRelationValue, relationKey) => { | ||
relationList.forEach((newRelationValue, relationAttributeName) => { | ||
const oldRelationValue = findOldRelation( | ||
@@ -185,3 +185,3 @@ newRelationValue, | ||
) { | ||
dirtyFields[key][relationKey] = newRelationValue; | ||
dirtyFields[key][relationAttributeName] = newRelationValue; | ||
@@ -204,6 +204,9 @@ return; | ||
if (dirtyFields[key][relationKey]) { | ||
Object.assign(dirtyFields[key][relationKey], recursiveDiff); | ||
if (dirtyFields[key][relationAttributeName]) { | ||
Object.assign( | ||
dirtyFields[key][relationAttributeName], | ||
recursiveDiff | ||
); | ||
} else { | ||
dirtyFields[key][relationKey] = recursiveDiff; | ||
dirtyFields[key][relationAttributeName] = recursiveDiff; | ||
} | ||
@@ -260,3 +263,3 @@ } | ||
const relationMetadata = this.mapping.getClassMetadataByKey( | ||
currentRelation.relationKey | ||
currentRelation.targetMetadataKey | ||
); | ||
@@ -267,3 +270,3 @@ | ||
`relation metadata is not set for relation ${classMetadata.key}.${ | ||
currentRelation.relationKey | ||
currentRelation.targetMetadataKey | ||
}` | ||
@@ -270,0 +273,0 @@ ); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1854193
19862
187