@cbnsndwch/zero-sources

ZeroTableSchema.createForClass() method

Home > @cbnsndwch/zero-nest-mongoose > ZeroTableSchema > createForClass

ZeroTableSchema.createForClass() method

Creates a zero table schema from a given Mongoose entity class.

TEntity - The type of the entity class. MUST extend mongoose.Document.

Signature:

static createForClass<TEntity extends Document<string, unknown, TEntity>>(target: Type<TEntity>): {
        name: string;
        primaryKey: readonly ["_id"];
        columns: ColumnsFromEntity<TEntity>;
    };

Parameters

Parameter

Type

Description

target

Type<TEntity>

The entity class to generate the schema from.

Returns:

{ name: string; primaryKey: readonly ["_id"]; columns: ColumnsFromEntity<TEntity>; }

The generated zero table schema.

Exceptions

Will throw an error if the collection name is missing in the entity's @Schema decorator.

How was this page?