generated from gxc-solutions/gxc-template-repo
Update models, added parser
This commit is contained in:
parent
0f8546bc69
commit
7742cc7a83
22 changed files with 449 additions and 41 deletions
|
|
@ -1,15 +1,5 @@
|
|||
import { ModelConstructor } from "../interfaces";
|
||||
export const IMMUTABLE_KEY = Symbol("secret");
|
||||
|
||||
export const IMMUTABLE_FIELDS = new WeakMap<ModelConstructor, Set<string>>();
|
||||
|
||||
export function immutable(value: unknown, context: ClassFieldDecoratorContext) {
|
||||
context.addInitializer(function () {
|
||||
const ctor = this.constructor as ModelConstructor;
|
||||
let set = IMMUTABLE_FIELDS.get(ctor);
|
||||
if (!set) {
|
||||
set = new Set<string>();
|
||||
IMMUTABLE_FIELDS.set(ctor, set);
|
||||
}
|
||||
set.add(context.name as string);
|
||||
});
|
||||
export function immutable(target: any, propertyKey: string) {
|
||||
Reflect.defineMetadata(IMMUTABLE_KEY, true, target, propertyKey);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue