Database Models

Since Burdy uses TypeORM there are a lot of resources that can be used to learn how to write new models and extend the existing system. To create a simple model (database persistent) the only caveat compared to using it with TypeORM is that you need to add it in the filter db/models.

For example to create a custom table named Customer that has fields firstName and lastName we first need to create an entity:

// customer.entity.ts

@Entity()
export default class Customer extends BaseEntity implements ICustomer {
  @PrimaryGeneratedColumn('increment')
  id: number;

  @Column({ nullable: true })
  firstName?: string;

  @Column({ nullable: true })
  lastName?: string;
}

And then in your project/index.ts use db/models filter to include your entity

Hooks.addFilter('db/models', async (args) => {
  return [
    Customer,
    ...args
  ];
});

If you are in dev mode please set TYPEORM_SYNCHRONIZE=true to automatically create new table. For production use burdy db migration scripts
Copyright © Burdy Technologies. All rights reserved.