Reduce(
Lambda(
['accumulator', 'ref'],
Append(
Get(Var('ref')),
Var('accumulator')
)
),
[],
Paginate(Documents(Collection('notifications')), {
size: 2
})
)
Will result to:
{
after: [Ref(Collection("notifications"), "296811454570430977")],
data: [
[
{
ref: Ref(Collection("notifications"), "295665276532294149"),
ts: 1619949211300000,
data: {
createdAt: "2021-04-12T11:33:50.342615Z",
updatedAt: "2021-05-02T09:53:31.133472Z"
}
},
{
ref: Ref(Collection("notifications"), "295666276580196871"),
ts: 1619943100860000,
data: {
createdAt: "2021-04-12T11:49:44.073589Z",
updatedAt: "2021-05-02T08:11:40.677455Z"
}
}
]
]
}
Notice how data is an array containing an array.
The expected output is:
{
after: [Ref(Collection("notifications"), "296811454570430977")],
data: [
{
ref: Ref(Collection("notifications"), "295665276532294149"),
ts: 1619949211300000,
data: {
createdAt: "2021-04-12T11:33:50.342615Z",
updatedAt: "2021-05-02T09:53:31.133472Z"
}
},
{
ref: Ref(Collection("notifications"), "295666276580196871"),
ts: 1619943100860000,
data: {
createdAt: "2021-04-12T11:49:44.073589Z",
updatedAt: "2021-05-02T08:11:40.677455Z"
}
}
]
}
The reason I’m using Reduce
is that in my app I’m doing Map
and then Filter
, I can combine those two loops by doing reduce but the output is unexpected.