[**Documentation**](../../../../README)

***

[Documentation](../../../../README) / [@zerotal/orm](../../README) / [index](../README) / ModelInspector

# Variable: ModelInspector

> `const` **ModelInspector**: `object`

Defined in: [packages/orm/src/schema/ModelInspector.ts:79](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/orm/src/schema/ModelInspector.ts#L79)

Reads model class metadata from `columnRegistry` (populated when a model's `@table`
decorator drains its queued `@column` registrations at class-definition time) and
returns a structured schema description for each registered model.

Prototype-chain walking: columns declared on a parent class are inherited
by child classes, matching normal TypeScript class semantics.

Used by `migrate:generate` to compare model intent against the live DB.

## Type Declaration

### load()

> **load**(`pattern`, `cwd?`): `Promise`\<`void`\>

Dynamically import all files matching `pattern` (relative to `cwd`).
Importing a model file runs its `@table` decorator, which registers the class's
columns into `columnRegistry` at definition time — so `all()` can enumerate them.

#### Parameters

##### pattern

`string`

##### cwd?

`string` = `...`

#### Returns

`Promise`\<`void`\>

### all()

> **all**(): [`ModelSchema`](../interfaces/ModelSchema)[]

Return a `ModelSchema` for every class registered in `columnRegistry`
that has a non-empty `static table` property.

Skips anonymous classes, the `BaseModel` base class, and any class that
hasn't set `static table`. Walks the prototype chain so that inherited
columns are included automatically.

#### Returns

[`ModelSchema`](../interfaces/ModelSchema)[]

### fromClass()

> **fromClass**(`ctor`): [`ModelSchema`](../interfaces/ModelSchema) \| `null`

Read the schema for a single model class.
Returns null if the class has no `static table` or no `@column()` fields
anywhere in its prototype chain.

#### Parameters

##### ctor

`Function`

#### Returns

[`ModelSchema`](../interfaces/ModelSchema) \| `null`
