I have a Student role which I created using this FQL
CreateRole({
name: "Student",
privileges: [
{
resource: Collection("Courses"),
actions: { read: true },
},
{
resource: Collection("Teachers"),
actions: { read: true },
},
],
membership: [
{
resource: Collection("Students"),
predicate: Query(
Lambda(
"ref",
Equals(Select(["data", "metadata", "role"], Get("ref")), "student")
)
),
},
],
});
When I try reading from the Courses collection using a server key like this
Paginate(Documents(Collection("Courses")), {size: 2})
I get this result
{
after: [Ref(Collection("Courses"), "277389193509865985")],
data: [
Ref(Collection("Courses"), "277389193509863937"),
Ref(Collection("Courses"), "277389193509864961")
]
}
But when I try reading from the collection using a token from a member of this role, I get this result
{data: []}
Here's a sample document from the Courses collection
{
"ref": Ref(Collection("Courses"), "277389193509863937"),
"ts": 1600797799527000,
"data": {
"title": "Liaison Technician",
"description": "Quam provident autem perferendis deserunt.",
"teachers": [],
"code": "LIA 241",
"availableFor": Ref(Collection("Classes"), "277389192880720389"),
"creditLoad": 2
}
}
Here's a sample document from the Students collection
{
"ref": Ref(Collection("Students"), "277362121690317319"),
"ts": 1600771983156000,
"data": {
"metadata": {
"firstName": "Loma",
"lastName": "Glover",
"email": "loma.glover@skulment.edu",
"role": "student",
"currentClass": "Grade 7"
}
}
}