ORDA: query in collection length?

How do I do this in ORDA?

Let’s say I want to find all invoices with more than one item: and my table Invoices had a relation pointing to items “Invoice_items”

$Col:=ds.Invoice.query(“Invoice_items.length > 1”)

I’ve tried this (different table & relation names, but same concept), and I get the error that “The “Invoice_items.length” attribute cannot be found in the “Invoice” datastore class”

I’ll take a beginner’s conceptual shot at this.

Say you have the unfiltered Invoice ID’s to test in $InvoiceID_Collection and
Invoice has a relation to the Invoice_Items named “Invoice_items_Link”
between [Invoices]ID and [Invoice_Items]InvoiceID then
you can get an Invoice_Item entity selection with:
$entSel_Invoice_Items:=ds.Invoice_Items.query(“Invoice_ID in :1”; $InvoiceID_Collection)

At this point we have all invoice items for all invoices.
<code 4D>
$MoreThan1_ID:=new collection
For Each($obj;$entSel_Invoice_Items)
$entSel_Small:=$entSel_Invoice_Items.query(“InvoiceID = :1”;$obj.ID)
if($entSel_Small.length>1)
$MoreThan1_ID.push($obj.ID) //build a collection of qualifying invoice IDs
end if
end for each
</code 4D>

Unless ORDA has some equivalent to the distinct values count parameter, I would lean toward…
USE ENTITY SELECTION($entSel_Invoice_Items)
DISTINCT VALUES ([Invoice_items]Parent_ID;$aParentID;$aParentIDCount)
SORT the pair and DELETE FROM $aParentID where $aParentIDCount < 2
QUERY Invoices with array $aParentID
$didItWithOrdaSorta:=Create entity selection([Parent])

: Tony RINGSMUTH

How do I do this in ORDA?

Let’s say I want to find all invoices with more than one item: and my
table Invoices had a relation pointing to items “Invoice_items”

$Col:=ds.Invoice.query(“Invoice_items.length > 1”)

I’ve tried this (different table & relation names, but same concept),
and I get the error that “The “Invoice_items.length” attribute cannot
be found in the “Invoice” datastore class”

Yes, starting with 4D v17R6:

<code 4D>
$formula:=Formula(This.Invoice_Items.length>1)
$o:=ds.Invoice.query($formula)
</code 4D>

Hi,

As said Christian, the query() member method has just been updated in v17R6

you can use a Formula with different ways

–> https://doc.4d.com/4Dv17R6/4D/17-R6/dataClassquery.305-4311816.en.html