Check out v4 of the Fauna CLI
v4 of the Fauna CLI is now in beta. The new version introduces enhancements to the developer experience, including an improved authentication workflow. To get started, check out the CLI v4 quick start. |
Object.select()
Get an Object property’s value by its path.
Return value
Type | Description |
---|---|
Value of the property at the path. If the path doesn’t exist or is undefined,
the value is |
Examples
Basic example
// Gets the value of the top-level `foo` property.
Object.select({ foo : 'bar' }, ['foo'])
"bar"
Nested property
// Defines an Object with customer data.
let customer = {
"name": "Ruby Von Rails",
"email": "ruby@example.com",
"address": {
"street": "87856 Mendota Court",
"city": "Washington",
"state": "DC",
"postalCode": "20220",
"country": "US"
}
}
// Gets the customer's nested `address.state` property.
Object.select(customer, ['address', 'state'])
"DC"
Retrieve a nested Object
// Defines an Object with customer data.
let customer = {
"name": "Ruby Von Rails",
"email": "ruby@example.com",
"address": {
"street": "87856 Mendota Court",
"city": "Washington",
"state": "DC",
"postalCode": "20220",
"country": "US"
}
}
// Gets the customer's nested `address` property,
// which is an Object.
Object.select(customer, ['address'])
{
street: "87856 Mendota Court",
city: "Washington",
state: "DC",
postalCode: "20220",
country: "US"
}
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!