๐งพ $from() Cheat Sheet (OpenAF Array Superpowers)
๐ Filtering
$from(arr).equals("key", "value").select()
$from(arr).greater("size", 1024).select()
$from(arr).contains("tags", "urgent").select()
$from(arr).where(r => r.name.startsWith("A")).select()
๐ Sorting
$from(arr).sort("name").select()
$from(arr).sort("-date", "priority").select() // "-" for descending
๐ท๏ธ Selecting/Mapping
$from(arr).select(r => ({ id: r.id, label: r.name.toUpperCase() }))
๐งฎ Aggregation
$from(arr).sum("amount") // total of amount fields
$from(arr).count() // count all
$from(arr).avg("score") // average score
$from(arr).max("age") // max age
๐งฉ Grouping
$from(arr).group("type").select()
Result: a list of { key: type, values: [โฆ] }
๐งน Distinct
$from(arr).distinct("category").select()
๐ Combining Sets
$from(arr1).intersect(arr2).select()
$from(arr1).except(arr2).select()
$from(arr1).cartesian(arr2).select()
๐งฐ Common Patterns
Get first match
$from(arr).equals("status", "active").at(0)
Chain filters
$from(arr).greater("price", 10).less("price", 100).select()
Use custom logic
$from(arr).where(r => r.date < now()).select()