Re: How to use collection.query for specific element of embedded collection

2019-04-26 Thread Keisuke Miyako via 4D_Tech
square brackets have a specific meaning in query by attribute

see Example 5

or

Linking array attribute query arguments (16R2 and later)

https://doc.4d.com/4Dv17/4D/17.1/QUERY-BY-ATTRIBUTE.301-4178904.en.html

> 2019/04/27 2:01、Kirk Brooks via 4D_Tech <4d_tech@lists.4d.com>のメール:
>
> $queryString:="fields[1].name = :1"
>
> But this throws an error:
>
> Array element reference must be a letter in the object path: fields[1].




**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: How to use collection.query for specific element of embedded collection

2019-04-26 Thread Christian Sakowski via 4D_Tech
Hi Kirk,

in your example it should work like:

$obj:=New object("id";"some string";"fields";New collection(New 
object("i";0;"name";"value1");New object("i";1;"name";"value2");New 
object("i";1;"name";"value3")))

$selection:=$obj.fields.query("(i == 1) && (name == :1)";"value2")


--

Grüße/Regards,
[heubach-media] | Christian Sakowski
christian.sakow...@heubach-media.de
Tel: +49/(0)40/41 455 455





> Am 26.04.2019 um 19:01 schrieb Kirk Brooks via 4D_Tech <4d_tech@lists.4d.com>:
> 
> Imagine a collection or entity selection populated with objects like:
> 
> {
> 
> id: "some string",
> 
> fields: [
> 
> {i:0, name:value1},
> 
> {i:1, name:value2},
> 
> {i:2, name:value3},
> 
> ...
> 
> ]
> 
> }
> 
> 
> I want to find collection elements by searching for 'fields[1].name' =
> someValue.
> That is, only matches on the second element.
> 
> I thought the query string would be:
> 
> $queryString:="fields[1].name = :1"
> 
> 
> But this throws an error:
> 
> Array element reference must be a letter in the object path: fields[1].
> 
> 
> The query works without attempting to limit it to the particular collection
> index.
> What's the correct syntax for this kind of query?
> 
> Thanks!
> 
> -- 
> Kirk Brooks
> San Francisco, CA
> ===
> 
> What can be said, can be said clearly,
> and what you can’t say, you should shut up about
> 
> *Wittgenstein and the Computer *
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **


--
heubach media
Osterfeldstr. 12-14 | Haus 1 | Eingang Nord
22529 Hamburg
tel: 040 / 52 10 59 - 10 | fax: -99
mail: i...@heubach-media.de
home: www.heubach-media.de
Geschäftsführer|CEO: Matthias Heubach

Mieten Sie Ihre Computer, iPads & Drucker für Ihre Events bei:
http://www.milo-rental.com

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen.
Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten 
haben,
informieren Sie bitte sofort den Absender und vernichten Sie diese Mail.
Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht 
gestattet.
 
This e-mail may contain confidential and/or privileged information.
If you are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail.
Any unauthorized copying, disclosure or distribution of the
material in this e-mail is strictly forbidden.
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: How to use collection.query for specific element of embedded collection

2019-04-26 Thread Jim Hays via 4D_Tech
Kirk,

You might try .find() or .findIndex() for that kind of thing.
I've only used .query() directly on attributes (field names) in entity
selections so far.

Jim

On Fri, Apr 26, 2019 at 1:01 PM Kirk Brooks via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> Imagine a collection or entity selection populated with objects like:
>
> {
>
> id: "some string",
>
> fields: [
>
> {i:0, name:value1},
>
> {i:1, name:value2},
>
> {i:2, name:value3},
>
> ...
>
> ]
>
> }
>
>
> I want to find collection elements by searching for 'fields[1].name' =
> someValue.
> That is, only matches on the second element.
>
> I thought the query string would be:
>
> $queryString:="fields[1].name = :1"
>
>
> But this throws an error:
>
> Array element reference must be a letter in the object path: fields[1].
>
>
> The query works without attempting to limit it to the particular collection
> index.
> What's the correct syntax for this kind of query?
>
> Thanks!
>
> --
> Kirk Brooks
> San Francisco, CA
> ===
>
> What can be said, can be said clearly,
> and what you can’t say, you should shut up about
>
> *Wittgenstein and the Computer *
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

How to use collection.query for specific element of embedded collection

2019-04-26 Thread Kirk Brooks via 4D_Tech
Imagine a collection or entity selection populated with objects like:

{

id: "some string",

fields: [

{i:0, name:value1},

{i:1, name:value2},

{i:2, name:value3},

...

]

}


I want to find collection elements by searching for 'fields[1].name' =
someValue.
That is, only matches on the second element.

I thought the query string would be:

$queryString:="fields[1].name = :1"


But this throws an error:

Array element reference must be a letter in the object path: fields[1].


The query works without attempting to limit it to the particular collection
index.
What's the correct syntax for this kind of query?

Thanks!

-- 
Kirk Brooks
San Francisco, CA
===

What can be said, can be said clearly,
and what you can’t say, you should shut up about

*Wittgenstein and the Computer *
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**