我们正在研究的内容:数据库实体
大家好!今天,我们在 Vast 开发了一项重要的新功能,该功能允许程序员在 Vast Studio 中创建和编辑数据库实体。

Vast 已经支持 Schemas(类似于 NestJS DTO),实体也类似;它们有名称、描述、继承和属性。但实体还面临着额外的挑战:
当前状态
Vast 的模式结构如下:
export interface IProperty { name: string; typeSignature: PropertyType; isOptional: boolean; validators: Validator[]; } export interface IClassextends OptionalTypeGraphNode { description: string | null; parentId: string; properties: P[]; } export interface ISchema extends IClass { inheritance: TypeRefPropertyType | null; }
未来状态
为了支持实体,我们需要创建一个扩展“IClass”的新接口:
export interface IEntityProperty extends IProperty {} export interface IEntity extends IClass{ properties: IEntityProperty[]; }
这使得我们可以定制实体的行为,但仍然从相同的基本接口扩展。
以下是实体在 Vast Studio 中的样子以及它是如何生成为 NestJS 代码的。
**Vast Studio 中的实体**

**NestJS 中的实体**
@Entity() export class AddressEntity { @PrimaryGeneratedColumn("uuid") id: string; @IsString() @Column() country: string; @IsNumber({}) @Column({ nullable: true, type: "float" }) phone: number | null; @IsString() @Column() state: string; @IsString() @Column() street: string; @IsString() @Column() suburb: string; @ValidateNested() @ManyToOne(() => UserEntity) user: UserEntity; }
有想法、建议或问题吗?请在下方告诉我们。或者免费下载 Vast Studio 并亲自试用:
https://www.getvast.app/