bashleigh / typeorm-polymorphic

Typeorm polymorphic relationship management
MIT License
198 stars 38 forks source link

Add support for typeorm ^0.3.0 #34

Closed dominicbachmann closed 1 year ago

dominicbachmann commented 1 year ago

I had to change quite a lot since the way of defining custom repositories has heavily changed. All the tests are passing. I've added one change that is not related to the typeorm upgrade because I tought that it is probably a bug (the change is marked with: // TODO: Not sure about this change (key was just id before).

Please let me know if this is a valid approach and if I can do anything else.

erishiraj commented 1 year ago

This merge will resolve my issue as well.

rpvsilva commented 1 year ago

Hi, nice work here. @bashleigh is it possible to merge this and publish a new version?

sashalikesplanes commented 1 year ago

Anything I can help with @bashleigh @dominicbachmann ? Would be awesome to finish the bump to typeorm ^0.3.0

bashleigh commented 1 year ago

@sashalikesplanes Yes please, could you fix your tests? Looks like they're not passing in github actions. Looks like config setup issues

rpvsilva commented 1 year ago

@dominicbachmann You just need to rebase with the master branch and it will be fixed

dominicbachmann commented 1 year ago

@dominicbachmann You just need to rebase with the master branch and it will be fixed

Will do

tiagomichaelsousa commented 1 year ago

Any further updates regarding this topic? 🚀

lowbits commented 1 year ago

Hey nice work, im curious i forked your branch and was trying the inverse of the provided example.

@Entity()
export class StoreEntity {
    @PrimaryGeneratedColumn()
    id: number;

    @PolymorphicChildren(() => [VisitorEntity, EmployeeEntity], {
        entityTypeId: 'id'
    })
    visitors: (VisitorEntity | EmployeeEntity)[];
}

@Entity()
export class VisitorEntity{
  @PrimaryGeneratedColumn()
  id: number;

  @PolymorphicParent(() => StoreEntity, {
    eager: true,
  })
  store?: StoreEntity;

  @Column()
  entityType: string;
}

@Entity()
export class EmployeeEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  entityType: string;

  @PolymorphicParent(() => StoreEntity, {
    eager: true,
  })
  store: StoreEntity;
}

But i think the provided package doesnt work with this example? Do you have any hints how to make it work?

Best

Tobi

jspizziri commented 1 year ago

After looking more closely at this PR, I've decided to submit a different approach to this upgrade.

Please see https://github.com/bashleigh/typeorm-polymorphic/pull/38 which explains the motivation.