Query an array of Jsonb objects using typeorm

Viewed 99

I have a array a typeorm entity structured as below

@Entity({ name: 'stockprice' })
export class PriceEntity {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column('varchar')
  address: string;

  @Column({
    type: 'jsonb',
    array: false,
    default: () => "'[]'",
    nullable: false,
  })
  stocktimeseries: Array<PricetimeLine>;

  @CreateDateColumn()
  createdAt: Date;

  @UpdateDateColumn()
  updatedAt: Date;
}

export interface PricetimeLine {
  volume?: string;

  close: string;

  low: string;

  open: string;

  high: string;

  tradeDate: string;
}

This is the query i am using

stockPriceRepository.createQueryBuilder('price').where({ stocktimeseries: { volume:'255' } }).getOne();

it works when i query the address field

i am have a challenge quering the stocktime series column

for example i would want to get records where the volume of a stocktimeseries is greather than 255

ps . I have little experience with typeorm and postgress

0 Answers
Related