//
// Copyright 2021 Vulcanize, Inc.
//

{{#each imports as | import |}}
import { {{~#each import.toImport}} {{this}} {{~#unless @last}}, {{~/unless}} {{~/each}} } from '{{import.from}}';
{{/each}}

@Entity()
{{#each indexOn as | index |}}
{{#if index.columns}}
@Index([
{{~#each index.columns}}'{{this}}'
{{~#unless @last}}, {{/unless}}
{{~/each}}]
{{~#if index.unique}}, { unique: true }{{/if}})
{{/if}}
{{/each}}
export class {{className}} {{~#if implements}} implements {{implements}} {{~/if}} {
  {{#each columns as | column |}}
  {{#if (compare column.columnType 'ManyToOne')}}
  @{{column.columnType}}({{column.lhs}} => {{column.rhs}}
  {{~#if column.columnOptions}}, {{/if}}
  {{~else}}
  @{{column.columnType}}(
  {{~#if column.pgType~}} '{{column.pgType}}'
  {{~#if column.columnOptions}}, {{/if}}
  {{~/if}}
  {{~/if}}
  {{~#if column.columnOptions}}{
  {{~#each column.columnOptions}} {{this.option}}: {{{this.value}}}
  {{~#unless @last}},{{/unless}}
  {{~/each}} }
  {{~/if}})
  {{column.name}}!: {{column.tsType}};
  {{~#unless @last}}

  {{/unless}}

  {{/each}}
}
