Skip to content

Commit 0146e58

Browse files
committed
fix(*): fix
1 parent 6ac6676 commit 0146e58

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

packages/plugin-js-lambda-microlib/src/SchemaParser.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,12 @@ export default class SchemaParser {
117117
(undefined !== ownedReferenceList) && (acc.ownedReferenceListFields[k] = ownedReferenceList);
118118
(validators && 0 < validators.length) && (acc.validators[k] = [...acc.validators[k], ...validators]);
119119
(authorizers && 0 < authorizers.length) && (acc.authorizers[k] = [...(acc.authorizers[k] || []), ...authorizers]);
120-
unique && (acc.validators[k].push({type: '@unique', config: {type: schema.name, index: k}}));
120+
if (unique) {
121+
if (undefined === value && undefined === updateValue) {
122+
acc.validators[k].push({type: '@unique', config: {type: schema.name, index: k}});
123+
}
124+
acc.fields[k].unique = true;
125+
}
121126
(undefined !== value) && (acc.values[k] = value);
122127
(undefined !== updateValue) && (acc.updateValues[k] = updateValue);
123128
(undefined !== defaultValue) && (acc.defaultValues[k] = defaultValue);
@@ -410,4 +415,4 @@ export default class SchemaParser {
410415
shortName: shortName || (name || '').replace(/^.+_([^_]+)$/, '$1'),
411416
};
412417
}
413-
}
418+
}

packages/plugin-registry-base/assets/code/microservice/type-mixin/code-generated.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ inputs:
99
prefix:
1010
type: string
1111
default: ''
12+
unique:
13+
type: boolean
14+
default: false
1215

1316
attributes:
1417
code:
15-
type: "<%- indexed ? '@' : '' %>string"
18+
type: "<%- unique ? '!' : '' %><%- indexed ? '@' : '' %>string"
1619
prefix: "<%- prefix || '' %>"
1720
value:
1821
type: "<%- generator %>"

0 commit comments

Comments
 (0)