@Entity()
class User extends BaseEntity {
@PrimaryGeneratedColumn() id: number;
@Column() email: string;
}
const user = User.create({ email: "a@b.com" });
await user.save();
const found = await User.findOneBy({ email: "a@b.com" });
Active Record
This is Active Record. The entity extends BaseEntity, and it saves and queries itself through its own instance and static methods.
It is not "Data Mapper". In TypeORM's Data Mapper style, the entity is a plain class. You save it through an injected repository or the entity manager, not through the entity itself.