Doing:
Filter(
Map(
Paginate(
Match(
Index("userGoalsBySortOrder"),
CurrentIdentity()
)
),
Lambda(
["sortOrder", "ref"],
Get(Var("ref"))
)
),
Lambda(
["doc"],
Not(
ContainsPath(
["data", "deletedAt"],
Var("doc")
)
)
)
)
will return variable-sized pages. Based on reply in Getting Error: Lambda expects an array with 3 elements. Array contains 1 - #4 by wallslide I can do Filter
before Paginate
but I’m not sure how to approach that as Match
will return the fields stored in the index rather than the whole document. So I end up with:
Map(
Paginate(
Filter(
Match(
Index("userGoalsBySortOrder"),
CurrentIdentity()
),
Lambda(
["data", "ref"],
Not(
ContainsPath(
["data", "deletedAt"],
Get(Var("ref"))
)
)
)
)
),
Lambda(
["sortOrder", "ref"],
Get(Var("ref"))
)
)
Notice the multiple to Get(Var("ref"))
, I needed to get it twice and also the need for 2 loops Filter
and then Map
I also tried:
Paginate(
Reduce(
Lambda(
["result", "data"],
Let(
{
doc: Get(
Select([1], Var("data"))
)
},
If(
ContainsPath(
["data", "deletedAt"],
Var("doc")
),
Var("result"),
Append(
Var("doc"),
Var("result")
)
)
)
),
[],
Match(
Index("userGoalsBySortOrder"),
Ref(Collection("users"), "322014450218434627")
)
)
)
But it throws an error:
Error: [
{
"position": [
"paginate"
],
"code": "invalid argument",
"description": "Ref or Set expected, Array provided."
}
]
I think because Reduce
is returning an array rather than @set
pointer for Paginate
.