FQL is a TypeScript-inspired language for querying and manipulating data. It supports complex joins, data transformations, and optional static typing. A key feature is User-Defined Functions (UDFs), which allow you to encapsulate business logic within the database.
Example of a relational query involving lookups and projections:
// Gets the first customer with an email of "alice.appleseed@example.com".
let customer = Customer.where(.email == "alice.appleseed@example.com")
.first()
// Gets the first order for the customer, sorted by descending creation time.
Order.where(.customer == customer)
.order(desc(.createdAt)).
first() {
// Projecting fields resolves references, similar to a SQL join.
customer {
name,
email
},
status,
createdAt,
items {
product {
name,
price,
stock,
category {
name
}
},
quantity
},
total
}