File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
templates/cli/lib/type-generation/languages Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ const { AttributeType } = require('../attribute');
6
6
const { LanguageMeta } = require("./language");
7
7
8
8
class TypeScript extends LanguageMeta {
9
- getType(attribute) {
9
+ getType(attribute, collections ) {
10
10
let type = ""
11
11
switch (attribute.type) {
12
12
case AttributeType.STRING:
@@ -29,7 +29,8 @@ class TypeScript extends LanguageMeta {
29
29
type = "boolean";
30
30
break;
31
31
case AttributeType.RELATIONSHIP:
32
- type = LanguageMeta.toPascalCase(attribute.relatedCollection);
32
+ const relatedCollection = collections.find(c => c.$id === attribute.relatedCollection);
33
+ type = LanguageMeta.toPascalCase(relatedCollection.name);
33
34
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') {
34
35
type = `${type}[]`;
35
36
}
@@ -86,7 +87,7 @@ export enum <%- toPascalCase(attribute.key) %> {
86
87
<% for (const [index, collection] of Object .entries(collections)) { -%>
87
88
export type <% - toPascalCase(collection.name) %> = Models.Document & {
88
89
<% for (const attribute of collection.attributes) { -%>
89
- <% - strict ? toCamelCase(attribute.key) : attribute.key %> : <% - getType(attribute) %> ;
90
+ <% - strict ? toCamelCase(attribute.key) : attribute.key %> : <% - getType(attribute, collections ) %> ;
90
91
<% } -%>
91
92
}<% if (index < collections.length - 1 ) { %>
92
93
<% } %>
You can’t perform that action at this time.
0 commit comments