Search code examples
typescriptpostgresqltypeormsingle-table-inheritance

Updating an entity's type in TypeORM single table inheritance


Is there any way to change an inheriting entity's type (in the DB) to a different entity type?


Solution

  • Convert entity with uid from OldType to NewType:

    await em.update(OldType, { uid: uid }, {[entityTypeColumnName]: 'NewType'})