postgres typeorm return untill sum of a column is greater than condition

Viewed 1158

I have an entity which has a column type bigint named price.

It is a very large table. I want to get data from this table until the price is greater than or equal to a number.

How can I achieve that without getting the entire table from result

@Entity()
export class myTable extends BaseEntity {
  @Column({type:"bigint})
  price:number
}

I want to get entities until the sum of the prices are greater than or equal to a number

const input: number = 50000
const result = await myTable.find(/*order by date and where sum (price) >= input*/)

What is the syntax and how can I do this? using baseEntity query or queryBuilder and preferably not the raw query result

1 Answers

I think you need to create a raw query using the query builder for this. You can refer to this regarding the query.

Related