Skip to content

feat(pinia-orm): Support of composite key for some relations#885

Merged
CodeDredd merged 1 commit intonext-releasefrom
pinia-orm-829
Jan 23, 2023
Merged

feat(pinia-orm): Support of composite key for some relations#885
CodeDredd merged 1 commit intonext-releasefrom
pinia-orm-829

Conversation

@CodeDredd
Copy link
Copy Markdown
Owner

@CodeDredd CodeDredd commented Jan 23, 2023

🔗 Linked issue

closes #829

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Adding support of composite keys for belongsTo, hasOne and hasMany. So you can do something like this:

  class Phone extends Model {
    static entity = 'phones'

    @Attr() declare id: number
    @Attr() declare userId: number
    @Attr() declare userSecondId: number
    @Str('') declare number: string
  }

  class User extends Model {
    static entity = 'users'

    static primaryKey = ['id', 'secondId']

    @Attr() declare id: number
    @Attr() declare secondId: number
    @Str('') declare name: string

    @HasOne(() => Phone, ['userId', 'userSecondId'])
      phone!: Phone | null
  }

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

- `belongsTo`
- `hasOne`
- `hasMany`

closes #829
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

Base: 99.67% // Head: 99.67% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (7fbec85) compared to base (390e022).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@              Coverage Diff              @@
##           next-release     #885   +/-   ##
=============================================
  Coverage         99.67%   99.67%           
=============================================
  Files                85       85           
  Lines              5552     5611   +59     
  Branches            488      503   +15     
=============================================
+ Hits               5534     5593   +59     
  Misses               17       17           
  Partials              1        1           
Impacted Files Coverage Δ
packages/pinia-orm/src/model/Model.ts 100.00% <100.00%> (ø)
...ia-orm/src/model/attributes/relations/BelongsTo.ts 100.00% <100.00%> (ø)
...inia-orm/src/model/attributes/relations/HasMany.ts 100.00% <100.00%> (ø)
...pinia-orm/src/model/attributes/relations/HasOne.ts 100.00% <100.00%> (ø)
...nia-orm/src/model/attributes/relations/Relation.ts 100.00% <100.00%> (ø)
...model/decorators/attributes/relations/BelongsTo.ts 100.00% <100.00%> (ø)
...c/model/decorators/attributes/relations/HasMany.ts 100.00% <100.00%> (ø)
...rc/model/decorators/attributes/relations/HasOne.ts 100.00% <100.00%> (ø)
packages/pinia-orm/src/query/Query.ts 99.80% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@CodeDredd CodeDredd merged commit 9928538 into next-release Jan 23, 2023
@CodeDredd CodeDredd deleted the pinia-orm-829 branch January 23, 2023 13:03
@CodeDredd CodeDredd mentioned this pull request Jan 23, 2023
CodeDredd added a commit that referenced this pull request Jan 24, 2023
* fix(pinia-orm): `new` doesnt fire creating or created hook (#808)

* fix(pinia-orm): `new` doesnt fire creating or created hook
closes #801

* refactor(pinia-orm): fix type

* refactor(pinia-orm): linting

* chore: Update sponsors

* perf(pinia-orm): Querying models with belongsToMany relation are extremely slow (#876)

closes #823

* feat(pinia-orm): Support of composite key for some relations (#885)

- `belongsTo`
- `hasOne`
- `hasMany`

closes #829

* chore: Update nuxt2comp example

* chore(normalizr): Add unpkg & jsdelivr support

* perf(pinia-orm): Improve caching for hydrated models (#889)

* perf(pinia-orm): Improve caching for hydrated models

* refactor(pinia-orm): add missing operations

* refactor(pinia-orm): removed json comparison

* refactor(pinia-orm): remove cached objects if deleted

closes #853

* chore(normalizr): upgrade eslint config packages

* chore: Set ci to node version 18

* chore: ignore playground for eslint

* chore: update linting for ci
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants