@@ -62,7 +62,6 @@ async function getRelations(model: ModelDefault): Promise<any[]> {
62
62
for ( const relation of relationsArray ) {
63
63
if ( hasRelations ( model . default , relation ) ) {
64
64
for ( const relationInstance of model . default [ relation ] ) {
65
-
66
65
const modelRelationPath = path . userModelsPath (
67
66
`${ relationInstance . model . name } .ts` ,
68
67
)
@@ -278,7 +277,7 @@ async function getPivotTables(
278
277
const pivotTable = [ ]
279
278
280
279
if ( 'belongsToMany' in model . default ) {
281
- for ( const belongsToManyRelation of model . default . belongsToMany ) {
280
+ for ( const belongsToManyRelation of model . default . belongsToMany ) {
282
281
const modelRelationPath = path . userModelsPath (
283
282
`${ belongsToManyRelation . model . name } .ts` ,
284
283
)
@@ -288,7 +287,7 @@ async function getPivotTables(
288
287
289
288
pivotTable . push ( {
290
289
table :
291
- belongsToManyRelation ?. pivotTable ||
290
+ belongsToManyRelation ?. pivotTable ||
292
291
`${ formattedModelName } _${ modelRelation . default . table } ` ,
293
292
firstForeignKey : belongsToManyRelation . firstForeignKey ,
294
293
secondForeignKey : belongsToManyRelation . secondForeignKey ,
@@ -325,7 +324,6 @@ async function generateModelString(
325
324
for ( const relationInstance of relations ) {
326
325
relationImports += `import ${ relationInstance . model } from './${ relationInstance . model } '\n\n`
327
326
}
328
-
329
327
330
328
for ( const relation of relations ) {
331
329
const modelRelation = relation . model
@@ -340,12 +338,14 @@ async function generateModelString(
340
338
const relationCount = getRelationCount ( relation . relationship )
341
339
342
340
if ( relationType === 'throughType' ) {
343
- const relationName = relation . relationName || formattedModelName + modelRelation
341
+ const relationName =
342
+ relation . relationName || formattedModelName + modelRelation
344
343
const throughRelation = relation . throughModel
345
344
const formattedThroughRelation = relation . throughModel . name . toLowerCase ( )
346
345
const throughTableRelation = throughRelation . table
347
- const foreignKeyThroughRelation = relation . throughForeignKey || formattedThroughRelation + '_id'
348
-
346
+ const foreignKeyThroughRelation =
347
+ relation . throughForeignKey || `${ formattedThroughRelation } _id`
348
+
349
349
relationMethods += `
350
350
async ${ relationName } () {
351
351
if (this.${ formattedModelName } .id === undefined)
0 commit comments