map()
Description
The map()
method creates a Set by applying the functionBody
to each value in the Set, and returns the new Set. The source
set isn’t changed.
If map()
is the last value in a query, the first page of the new
Set is returned.
Writes are not permitted by functionBody.
Examples
For all Customer documents, combine the firstName
and lastName
properties into a single string:
Customer.all().map(
customer => "#{customer.firstName} #{customer.lastName}"
)
{
data: [
"Alice Appleseed",
"Bob Brown",
"Carol Clark"
]
}
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!