Query in an OB Array Object

If I have an OBJECT field in a datafile - ds.Table.ObjectField

and the field is populated by a TEXT array $a_uuid, comprising of a list of uuids, using

OB SET ARRAY([Table]ObjectField;“uuids”;$a_uuid)

Is there any way I can use ORDA to directly query ds.Table.ObjectField for any entities that contain a specific UUID?

Currently I am loading each record using a for each loop, calling OB Get Array, parsing the array, including the record if there is a match and looping on the the next record, but this seems very cumbersome

Did you try this:
<code 4D>
$table.query(“ObjectField.uuids[].uuid= :1”;$uuid)

</code 4D>
HTH
Lutz

Use the ORDA query method’s
https://doc.4d.com/4Dv18/4D/18/dataClassquery.305-4505887.en.htmlIN>
operator.

I’m assuming from your description that:

ds.Table.ObjectField.uuids is a collection of text

So construct your ORDA query like this:

First build a collection of uuids you want to find:

<code 4D>
$uuids_to_find_c:=New collection
$uuids_to_find_c.push(“a uuid you want to find”)
$uuids_to_find_c.push(“another uuid you want to find”)
$uuids_to_find_c.push(“and another uuid you want to find”)
</code 4D>

Then perform query with the IN operator:

<code 4D>
$found_eso:=ds.Table.query(“ObjectField.data[] IN :1”;$uuids_to_find_c)
</code 4D>

See “https://doc.4d.com/4Dv18/4D/18/QUERY-BY-ATTRIBUTE.301-4505135.en.html#3181657Linking array attribute query arguments>” for information on the “uuids[]” syntax.

Thanks Jeremy, this worked brilliantly, I really appreciate your help

Is QUERY BY ATTRIBUTE also how I work around the fact I use a remote datastore, so the USE ENTITY SELECTION doesn’t have any effect?

ORDA seems to sort out so many problems using remote datastore, like messing about with NAMED SELECTIONS, but also is a bit obscure in other ways!