Skip to content

Commit 2354e5e

Browse files
committed
chore: wip
1 parent 49873ef commit 2354e5e

File tree

5 files changed

+16
-13299
lines changed

5 files changed

+16
-13299
lines changed

app/Models/User.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ export default {
4747
// useUuid: true, // defaults to false
4848
},
4949

50-
hasOneThrough:[
50+
hasOneThrough: [
5151
{
5252
model: Post,
53-
through: Subscriber
54-
}
53+
through: Subscriber,
54+
},
5555
],
5656

5757
attributes: {

storage/framework/core/actions/src/orm/generate-model.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ async function getRelations(model: ModelDefault): Promise<any[]> {
6262
for (const relation of relationsArray) {
6363
if (hasRelations(model.default, relation)) {
6464
for (const relationInstance of model.default[relation]) {
65-
6665
const modelRelationPath = path.userModelsPath(
6766
`${relationInstance.model.name}.ts`,
6867
)
@@ -278,7 +277,7 @@ async function getPivotTables(
278277
const pivotTable = []
279278

280279
if ('belongsToMany' in model.default) {
281-
for (const belongsToManyRelation of model.default.belongsToMany) {
280+
for (const belongsToManyRelation of model.default.belongsToMany) {
282281
const modelRelationPath = path.userModelsPath(
283282
`${belongsToManyRelation.model.name}.ts`,
284283
)
@@ -288,7 +287,7 @@ async function getPivotTables(
288287

289288
pivotTable.push({
290289
table:
291-
belongsToManyRelation?.pivotTable ||
290+
belongsToManyRelation?.pivotTable ||
292291
`${formattedModelName}_${modelRelation.default.table}`,
293292
firstForeignKey: belongsToManyRelation.firstForeignKey,
294293
secondForeignKey: belongsToManyRelation.secondForeignKey,
@@ -325,7 +324,6 @@ async function generateModelString(
325324
for (const relationInstance of relations) {
326325
relationImports += `import ${relationInstance.model} from './${relationInstance.model}'\n\n`
327326
}
328-
329327

330328
for (const relation of relations) {
331329
const modelRelation = relation.model
@@ -340,12 +338,14 @@ async function generateModelString(
340338
const relationCount = getRelationCount(relation.relationship)
341339

342340
if (relationType === 'throughType') {
343-
const relationName = relation.relationName || formattedModelName + modelRelation
341+
const relationName =
342+
relation.relationName || formattedModelName + modelRelation
344343
const throughRelation = relation.throughModel
345344
const formattedThroughRelation = relation.throughModel.name.toLowerCase()
346345
const throughTableRelation = throughRelation.table
347-
const foreignKeyThroughRelation = relation.throughForeignKey || formattedThroughRelation + '_id'
348-
346+
const foreignKeyThroughRelation =
347+
relation.throughForeignKey || `${formattedThroughRelation}_id`
348+
349349
relationMethods += `
350350
async ${relationName}() {
351351
if (this.${formattedModelName}.id === undefined)

0 commit comments

Comments
 (0)