ToArray

Not available in this language yet.
ToArray( object )
ToArray( object )
ToArray( object )
to_array( object )
ToArray( object )

Description

The ToArray function converts an Object to an Array, if possible.

If conversion cannot be completed, for any reason, an "invalid argument" error is returned.

Parameters

Argument Type Definition and Requirements

object

The object to convert to an array.

Returns

An array composed from the provided object.

Examples

The following query uses ToArray to convert an object into an array:

Not available in this language yet.
result, err := client.Query(
	f.ToArray(
		f.Obj{
			"name": "Dennis",
			"age": 37,
		}))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
[[age 37] [name Dennis]]
System.out.println(
    client.query(
        ToArray(
            Obj("name", Value("Dennis"), "age", Value(37))
        )
    ).get());
[["name", "Dennis"], ["age", 37]]
client.query(
  q.ToArray({ name: 'Dennis', age: 37 })
)
.then((ret) => console.log(ret))
.catch((err) => console.error('Error: %s', err))
[ [ 'name', 'Dennis' ], [ 'age', 37 ] ]
result = client.query(
  q.to_array({"name": "Dennis", "age": 37})
)
print(result)
[['name', 'Dennis'], ['age', 37]]
  println(Await.result(
    client.query(
      ToArray(
        Obj("name" -> "Dennis", "age" -> 37)
      )
    ),
    5.seconds
  ))
[["name", "Dennis"], ["age", 37]]

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!