I am trying to update materialized path in SQLite3 database with usage of TypeORM. The table for folders (which I am updating) has both parent and parentId columns. When I update parent column, the parentId column is going to update, but not the mpath column.
I tried using both getRepository() and getTreeRepository() for update.
I am not really sure what else to add, see attached model and update method below.
Model
@Entity()
@Tree('materialized-path')
export class Folder {
@PrimaryGeneratedColumn()
id: number;
@Column({
type: 'varchar',
length: 50
})
title: string;
@TreeParent()
parent: Folder;
@TreeChildren()
children: Folder[];
@Column({
nullable: true
})
parentId: number;
Update
await connection.getTreeRepository<Folder>(Folder).update(id, {
parent: await connection.getRepository<Folder>(Folder).findOne(parentId)
});