CreateIndex({
name: 'userGoalsBySortOrder',
source: Collection('goals'),
terms: [
{ field: ['data', 'user'] },
{ field: ['data', 'deletedAt'] }
],
values: [
{ field: ['data', 'sortOrder'], reverse: true },
{ field: ['ref'] }
]
})
Custom query: getUserGoals
Update(Function("getUserGoals"), {
role: "admin",
body: Query(
Lambda(
["size", "afterCursor", "beforeCursor"],
Map(
Paginate(
Match(
Index("userGoalsBySortOrder"),
CurrentIdentity(),
null
)
),
Lambda(
["sortOrder", "ref"],
Get(Var("ref"))
)
)
)
)
});
If I manually run this function, it works as I expect it to work, but if I use it with graphql, I always get an empty data back.
The only thing “partially works” (but doesn’t give the result I want) is this:
CreateIndex({
name: 'userGoalsBySortOrder',
source: Collection('goals'),
terms: [
{ field: ['data', 'user'] }
],
values: [
{ field: ['data', 'sortOrder'], reverse: true },
{ field: ['ref'] }
]
})
This will give me “ALL” records, even those with deletedAt