Skip to content

Commit

Permalink
Merge pull request #191 from AthennaIO/develop
Browse files Browse the repository at this point in the history
chore(npm): update dependencies
  • Loading branch information
jlenon7 authored Feb 9, 2025
2 parents 59d40f2 + acd46b9 commit 9495c89
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/database",
"version": "5.12.0",
"version": "5.13.0",
"description": "The Athenna database handler for SQL/NoSQL.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion src/models/BaseModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ export class BaseModel {
return
}

json[key] = this[key].toJSON ? this[key].toJSON() : this[key]
json[key] = this[key]?.toJSON ? this[key].toJSON() : this[key]

return
}
Expand Down
2 changes: 1 addition & 1 deletion src/models/annotations/BelongsTo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function BelongsTo<T extends BaseModel = any, R extends BaseModel = any>(

options = Options.create(options, {
isIncluded: false,
// Default will be set later as: RelationModel.schema().getMainPrimaryKeyName()
// Default will be set later as: RelationModel.schema().getMainPrimaryKeyProperty()
primaryKey: undefined,
// Default will be set later as: `${String.toCamelCase(RelationModel.name)}Id`
foreignKey: undefined
Expand Down
2 changes: 1 addition & 1 deletion src/models/annotations/HasMany.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function HasMany<T extends BaseModel = any, R extends BaseModel = any>(

options = Options.create(options, {
isIncluded: false,
primaryKey: Target.schema().getMainPrimaryKeyName(),
primaryKey: Target.schema().getMainPrimaryKeyProperty(),
foreignKey: `${String.toCamelCase(Target.name)}Id`
})

Expand Down
2 changes: 1 addition & 1 deletion src/models/annotations/HasOne.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function HasOne<T extends BaseModel = any, R extends BaseModel = any>(

options = Options.create(options, {
isIncluded: false,
primaryKey: Target.schema().getMainPrimaryKeyName() as any,
primaryKey: Target.schema().getMainPrimaryKeyProperty() as any,
foreignKey: `${String.toCamelCase(Target.name)}Id` as any
})

Expand Down
2 changes: 1 addition & 1 deletion src/models/relations/BelongsTo/BelongsToRelation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class BelongsToRelation {
const RelationModel = relation.model()

relation.primaryKey =
relation.primaryKey || RelationModel.schema().getMainPrimaryKeyName()
relation.primaryKey || RelationModel.schema().getMainPrimaryKeyProperty()
relation.foreignKey =
relation.foreignKey || `${String.toCamelCase(RelationModel.name)}Id`

Expand Down
3 changes: 2 additions & 1 deletion src/models/relations/BelongsToMany/BelongsToManyRelation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export class BelongsToManyRelation {
const PivotModel = relation.pivotModel()

relation.pivotTable = relation.pivotTable || PivotModel.table()
relation.relationPrimaryKey = RelationModel.schema().getMainPrimaryKeyName()
relation.relationPrimaryKey =
RelationModel.schema().getMainPrimaryKeyProperty()
relation.relationForeignKey = `${String.toCamelCase(RelationModel.name)}Id`

return relation
Expand Down

0 comments on commit 9495c89

Please sign in to comment.