Comparing version 5.1.1 to 5.2.0
@@ -577,3 +577,3 @@ 'use strict'; | ||
neededDataSources: ['primary'], | ||
allowMultiValued: false | ||
allowMultiValued: true | ||
}, | ||
@@ -585,3 +585,3 @@ context | ||
context.parentResource = attrNode; | ||
context.parentResource = childResource; | ||
} | ||
@@ -588,0 +588,0 @@ |
@@ -230,7 +230,13 @@ 'use strict'; | ||
}; | ||
['attributePath', 'dataSourceName', 'childKey', 'parentKey', 'multiValuedParentKey', 'uniqueChildKey'].forEach( | ||
(key) => { | ||
if (Object.prototype.hasOwnProperty.call(dst, key)) mainResults[key] = dst[key]; | ||
} | ||
); | ||
[ | ||
'attributePath', | ||
'dataSourceName', | ||
'childKey', | ||
'parentKey', | ||
'multiValuedParentKey', | ||
'uniqueChildKey', | ||
'multiValuedChildKey' | ||
].forEach((key) => { | ||
if (Object.prototype.hasOwnProperty.call(dst, key)) mainResults[key] = dst[key]; | ||
}); | ||
@@ -237,0 +243,0 @@ if (!dst._isEmpty) { |
@@ -762,2 +762,3 @@ 'use strict'; | ||
subResourceTree.childKey = attrNode.resolvedChildKey; | ||
subResourceTree.multiValuedChildKey = false; | ||
attrNode.childKey.forEach((childKeyAttrPath) => { | ||
@@ -770,2 +771,5 @@ const childKeyAttrNode = getAttribute(childKeyAttrPath, attrNode, context); | ||
}); | ||
if (childKeyAttrNode.multiValued && attrNode.childKey.length === 1) { | ||
subResourceTree.multiValuedChildKey = true; | ||
} | ||
}); | ||
@@ -1097,2 +1101,5 @@ | ||
} | ||
if ('multiValuedChildKey' in resourceTree) { | ||
dataSourceTree.multiValuedChildKey = resourceTree.multiValuedChildKey; | ||
} | ||
} | ||
@@ -1130,2 +1137,3 @@ | ||
uniqueChildKey: true, | ||
multiValuedChildKey: false, | ||
request: dataSources[dataSourceName] | ||
@@ -1220,2 +1228,3 @@ }; | ||
uniqueChildKey: originalDataSourceTree.uniqueChildKey, | ||
multiValuedChildKey: false, | ||
request: joinDataSource, | ||
@@ -1228,2 +1237,5 @@ attributeOptions: joinDataSource.attributeOptions, | ||
if (resourceTree.resourceName) dataSourceTree.resourceName = resourceTree.resourceName; | ||
if (resourceTree.extensions) dataSourceTree.extensions = resourceTree.extensions; | ||
delete joinDataSource.attributeOptions; | ||
@@ -1230,0 +1242,0 @@ delete joinDataSource.joinParentKey; |
@@ -55,19 +55,25 @@ 'use strict'; | ||
const key = keyAttr | ||
? '' + dereferenceKeyAttr(keyAttr) // speed up non-composite keys | ||
let keyValues = keyAttr | ||
? dereferenceKeyAttr(keyAttr) // speed up non-composite keys | ||
: rawResult.childKey.map(dereferenceKeyAttr).join(keySeparator); | ||
if (!rawResult.uniqueChildKey) { | ||
if (!rawResult.indexedData[key]) rawResult.indexedData[key] = []; | ||
rawResult.indexedData[key].push(row); | ||
} else { | ||
if (rawResult.indexedData[key]) { | ||
const attrPath = | ||
rawResult.attributePath.length > 0 ? rawResult.attributePath.join('.') : '{root}'; | ||
throw new DataError( | ||
`Result-row ${i} of "${attrPath}" (DataSource "${rawResult.dataSourceName}") has duplicate child key "${key}"` | ||
); | ||
if (!rawResult.multiValuedChildKey) { | ||
keyValues = ['' + keyValues]; | ||
} | ||
keyValues.forEach((key) => { | ||
if (!rawResult.uniqueChildKey) { | ||
if (!rawResult.indexedData[key]) rawResult.indexedData[key] = []; | ||
rawResult.indexedData[key].push(row); | ||
} else { | ||
if (rawResult.indexedData[key]) { | ||
const attrPath = | ||
rawResult.attributePath.length > 0 ? rawResult.attributePath.join('.') : '{root}'; | ||
throw new DataError( | ||
`Result-row ${i} of "${attrPath}" (DataSource "${rawResult.dataSourceName}") has duplicate child key "${key}"` | ||
); | ||
} | ||
rawResult.indexedData[key] = row; | ||
} | ||
rawResult.indexedData[key] = row; | ||
} | ||
}); | ||
}); | ||
@@ -74,0 +80,0 @@ } |
{ | ||
"name": "flora", | ||
"version": "5.1.1", | ||
"version": "5.2.0", | ||
"description": "FLexible Open Rest API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
183608
4260