SelectAll

SelectAll( path, from )
SelectAll( path, from )
SelectAll( path, from )
SelectAll( path, from )
select_all( path, from )
SelectAll( path, from )
SelectAll( path, from )
Not available in this language yet.

Description

The SelectAll function extracts one or more values from a document. It is very useful when extracting multiple values in an array. It extracts all of the values specified by the path parameter out of the from parameter and returns the values as an Array. If the path does not exist an empty array is returned.

This function is not comparable to SQL’s SELECT command. If you are looking to fetch documents from a collection, see Paginate.

Parameter

Argument Type Definition and Requirements

path

The path to the field in the document to extract

from

The object or array containing the data to be extracted.

Returns

The value(s) specified by the path.

Examples

The following query extracts all of the name fields from the provided array, by using a string-based path:

Value result = await client.Query(
  SelectAll(
    Arr("people", "name"),
    Obj(
      "people", Arr(
        Obj("name", "Jane"),
        Obj("name", "John"),
        Obj("name", "Thomas")
      )
    )
  )
);
result, err := client.Query(
  f.SelectAll(
    f.Arr{"people", "name"},
    f.Obj{
      "people": f.Arr{
        f.Obj{ "name": "Jane" },
        f.Obj{ "name": "John" },
        f.Obj{ "name": "Thomas" }}}))
System.out.println(
    client.query(
        SelectAll(
            Arr(Value("people"), Value("name")),
            Obj(
                "people",
                Arr(
                    Obj("name", Value("Jane")),
                    Obj("name", Value("John")),
                    Obj("name", Value("Thomas"))
                )
            )
        )
    ).get());
client.query(
  q.SelectAll(
    ['people', 'name'],
    {
      'people': [
        { 'name': 'Jane' },
        { 'name': 'John' },
        { 'name': 'Thomas' },
      ],
    },
  )
)
.then((ret) => console.log(ret))
print(client.query(
  q.select_all(
    ["people", "name"],
    {
      "people": [
        { "name": "Jane" },
        { "name": "John" },
        { "name": "Thomas" },
      ],
    },
  )
))
Not available in this language yet.
println(Await.result(
  client.query(
    SelectAll(
      Arr("people", "name"),
      Obj(
        "people" -> Arr(
          Obj("name" -> "Jane"),
          Obj("name" -> "John"),
          Obj("name" -> "Thomas")
        )
      )
    )
  ),
  5.seconds
))
Not available in this language yet.
[
  "Jane",
  "John",
  "Thomas"
]
[Jane John Thomas]
["Jane", "John", "Thomas"]
[ 'Jane', 'John', 'Thomas' ]
['Jane', 'John', 'Thomas']
["Jane", "John", "Thomas"]

The following query extracts all of the first names from the name fields, by using a path that includes a numeric index:

Value result = await client.Query(
  SelectAll(
    Arr("name", 0),
    Arr(
      Obj("name", Arr("Jane", "Eyre")),
      Obj("name", Arr("John", "Connor")),
      Obj("name", Arr("Thomas", "Magnum"))
    )
  )
);
result, err := client.Query(
  f.SelectAll(
    f.Arr{"name", 0},
    f.Arr{
      f.Obj{"name": f.Arr{"Jane", "Eyre"}},
      f.Obj{"name": f.Arr{"John", "Connor"}},
      f.Obj{"name": f.Arr{"Thomas", "Magnum"}}}))
System.out.println(
    client.query(
        SelectAll(
            Arr(Value("name"), Value(0)),
            Arr(
                Obj("name", Arr(Value("Jane"), Value("Eyre"))),
                Obj("name", Arr(Value("John"), Value("Connor"))),
                Obj("name", Arr(Value("Thomas"), Value("Magnum")))
            )
        )
    ).get());
client.query(
  q.SelectAll(
    ['name', 0],
    [
      { 'name': [ 'Jane', 'Eyre' ] },
      { 'name': [ 'John', 'Connor' ] },
      { 'name': [ 'Thomas', 'Magnum' ] },
    ],
  )
)
.then((ret) => console.log(ret))
print(client.query(
  q.select_all(
    ["name", 0],
    [
      {"name": ["Jane", "Eyre"]},
      {"name": ["John", "Connor"]},
      {"name": ["Thomas", "Magnum"]}
    ]
  )
))
Not available in this language yet.
println(Await.result(
  client.query(
    SelectAll(
      Arr("name", 0),
      Arr(
        Obj("name" -> Arr("Jane", "Eyre")),
        Obj("name" -> Arr("John", "Connor")),
        Obj("name" -> Arr("Thomas", "Magnum"))
      )
    )
  ),
  5.seconds
))
Not available in this language yet.
[
  "Jane",
  "John",
  "Thomas"
]
[Jane John Thomas]
["Jane", "John", "Thomas"]
[ 'Jane', 'John', 'Thomas' ]
['Jane', 'John', 'Thomas']
["Jane", "John", "Thomas"]

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve! documentation@fauna.com

Thank you for your feedback!