How can I query this

I want to query all the items that have an active Listing (not cancelled and sold_quantity < quantity) as an object that look like this
type Item = {
  id: number;
  name: string;
  (all item attributes)
  listings: {
    id: number;
    user_id: string;
    quantity: number;
    price: number;
    price_item?: {(all item attributes)};
    sold_quantity: number;
    cancelled: boolean;
    created_at: Date;
  }[]

Is that possible using supabase to do it in only 1 query or do I have to do multiple queries ?
image.png
Was this page helpful?