Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cdf3a54

Browse files
nounderkoskimas
authored andcommitted
Add typings for Relations
1 parent 045fe74 commit cdf3a54

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

typings/objection/index.d.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,23 @@ declare namespace Objection {
183183
[relationName: string]: RelationMapping;
184184
}
185185

186+
interface RelationProperty {
187+
size: number;
188+
modelClass: Model;
189+
props: string[];
190+
cols: string[];
191+
}
192+
186193
interface Relation {
187-
// TODO should this be something other than a tagging interface?
194+
name: string;
195+
ownerModelClass: Model;
196+
relatedModelClass: Model;
197+
ownerProp: RelationProperty;
198+
relatedProp: RelationProperty;
199+
joinModelClass: Function;
200+
joinTable: string;
201+
joinTableOwnerProp: RelationProperty;
202+
joinTableRelatedProp: RelationProperty;
188203
}
189204

190205
export interface RelationJoin {
@@ -462,6 +477,8 @@ declare namespace Objection {
462477
static WhereInEagerAlgorithm: EagerAlgorithm;
463478
static NaiveEagerAlgorithm: EagerAlgorithm;
464479

480+
static getRelations(): { [key: string]: Relation }
481+
465482
static query<QM extends Model>(
466483
this: Constructor<QM>,
467484
trxOrKnex?: Transaction | knex

0 commit comments

Comments
 (0)