TypeORM Transform Objecto into Entity

Viewed 17

Is there any way to transform an object into an TypeORM entity?

I updated a "Slot entity" using typeorm query builder

await Slot
        .createQueryBuilder()
          .update(Slot)
          .set({
            status: 'void',
            voidReason: 'Billing - incomplete verification'
          })
          .where("start_date > NOW() - INTERVAL '14 days'")
          .andWhere("status = 'void'")
          .returning("*")
          .execute();

But it returns me an array of objects

Is there any way to transform these objects into the Entity Slot instance?

Like below:

Slot {
  index: 72,
  x: 'd7301',
  y: 'k',
  startType: 'new'
}

I tried using

entityRepository = getRepository(Slot)
entitySlot = entityRepository.create(slot)

where slot is the object But if in the object i have like test_id, and in the entity is testId, all the field with "_" aren't created in the entity

0 Answers
Related