(model: string, items: unknown)
| 2021 | } |
| 2022 | |
| 2023 | private injectCompoundId(model: string, items: unknown) { |
| 2024 | const typeInfo = this.getModelInfo(model); |
| 2025 | if (!typeInfo) { |
| 2026 | return; |
| 2027 | } |
| 2028 | |
| 2029 | // recursively traverse the entity to create synthetic ID field for models with compound ID |
| 2030 | enumerate(items).forEach((item: any) => { |
| 2031 | if (!item) { |
| 2032 | return; |
| 2033 | } |
| 2034 | |
| 2035 | if (typeInfo.idFields.length > 1) { |
| 2036 | item[this.makeIdKey(typeInfo.idFields)] = this.makeCompoundId(typeInfo.idFields, item); |
| 2037 | } |
| 2038 | |
| 2039 | for (const [key, value] of Object.entries(item)) { |
| 2040 | if (typeInfo.relationships[key]) { |
| 2041 | // field is a relationship, recurse |
| 2042 | this.injectCompoundId(typeInfo.relationships[key].type, value); |
| 2043 | } |
| 2044 | } |
| 2045 | }); |
| 2046 | } |
| 2047 | |
| 2048 | private toPlainObject(data: any): any { |
| 2049 | if (data === undefined || data === null) { |
no test coverage detected