Skip to content

Commit 6394862

Browse files
committed
chore: fix some typings and styles
1 parent b3821f7 commit 6394862

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/model/Model.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { isNullish, isArray, assert } from '../support/Utils'
22
import { Element, Item, Collection } from '../data/Data'
3+
import { Database } from '../database/Database'
34
import { Query } from '../query/Query'
45
import { NonEnumerable } from './decorators/NonEnumerable'
56
import { Attribute } from './attributes/Attribute'
@@ -13,7 +14,6 @@ import { HasOne } from './attributes/relations/HasOne'
1314
import { BelongsTo } from './attributes/relations/BelongsTo'
1415
import { HasMany } from './attributes/relations/HasMany'
1516
import { HasManyBy } from './attributes/relations/HasManyBy'
16-
import { Database } from '@/database/Database'
1717

1818
export type ModelFields = Record<string, Attribute>
1919
export type ModelSchemas = Record<string, ModelFields>
@@ -100,7 +100,11 @@ export class Model {
100100
/**
101101
* Set the attribute to the registry.
102102
*/
103-
static setRegistry(key: string, attribute: () => Attribute): typeof Model {
103+
static setRegistry<M extends typeof Model>(
104+
this: M,
105+
key: string,
106+
attribute: () => Attribute
107+
): M {
104108
if (!this.registries[this.entity]) {
105109
this.registries[this.entity] = {}
106110
}
@@ -128,7 +132,7 @@ export class Model {
128132
/**
129133
* Create a new model instance without field values being populated.
130134
*
131-
* This method is mainly fo the internal use when registering models to the
135+
* This method is mainly for the internal use when registering models to the
132136
* database. Since all pre-registered models are for referencing its model
133137
* setting during the various process, but the fields are not required.
134138
*

0 commit comments

Comments
 (0)