@@ -128,6 +128,14 @@ user.Age in 18..45 and user.Name not in ["admin", "root"]
128
128
foo matches "^[A-Z].*"
129
129
```
130
130
131
+ ``` expr
132
+ tweets | filter(.Size < 280) | map(.Content) | join(" -- ")
133
+ ```
134
+
135
+ ``` expr
136
+ filter(posts, {now() - .CreatedAt >= 7 * duration("24h")})
137
+ ```
138
+
131
139
### Membership Operator
132
140
133
141
Fields of structs and items of maps can be accessed with ` . ` operator
@@ -185,6 +193,16 @@ For example, expression `split(lower(user.Name), " ")` can be written as:
185
193
user.Name | lower() | split(" ")
186
194
```
187
195
196
+ ### Date Manipulation
197
+
198
+ The following operators can be used to manipulate dates:
199
+
200
+ ``` expr
201
+ date("2023-08-14") + duration("1h")
202
+ date("2023-08-14") - duration("1h")
203
+ date("2023-08-14") - date("2023-08-13") == duration("24h")
204
+ ```
205
+
188
206
## Built-in Functions
189
207
190
208
### all(array, predicate)
@@ -193,7 +211,7 @@ Returns **true** if all elements satisfies the [predicate](#predicate).
193
211
If the array is empty, returns ** true** .
194
212
195
213
``` expr
196
- all(Tweets , {.Size < 280})
214
+ all(tweets , {.Size < 280})
197
215
```
198
216
199
217
### any(array, predicate)
@@ -207,7 +225,7 @@ Returns **true** if _exactly one_ element satisfies the [predicate](#predicate).
207
225
If the array is empty, returns ** false** .
208
226
209
227
``` expr
210
- one(Participants , {.Winner})
228
+ one(participants , {.Winner})
211
229
```
212
230
213
231
### none(array, predicate)
@@ -221,7 +239,7 @@ Returns new array by applying the [predicate](#predicate) to each element of
221
239
the array.
222
240
223
241
``` expr
224
- map(Tweets , {.Size})
242
+ map(tweets , {.Size})
225
243
```
226
244
227
245
### filter(array, predicate)
@@ -673,19 +691,20 @@ If items of the array is a struct or a map, it is possible to access fields with
673
691
omitted ` # ` symbol (` #.Value ` becomes ` .Value ` ).
674
692
675
693
``` expr
676
- filter(Tweets , {len(.Value) > 280})
694
+ filter(tweets , {len(.Value) > 280})
677
695
```
678
696
679
697
Braces ` { ` ` } ` can be omitted:
680
698
681
699
``` expr
682
- filter(Tweets , len(.Value) > 280)
700
+ filter(tweets , len(.Value) > 280)
683
701
```
684
702
685
703
## ` $env ` variable
686
704
687
705
The ` $env ` variable is a map of all variables passed to the expression.
688
706
689
707
``` expr
690
- Foo.Name == $env["Foo"].Name
708
+ foo.Name == $env["foo"].Name
709
+ $env["var with spaces"]
691
710
```
0 commit comments