How to read an index document while using a user role?

So I made a function that reads an index document to generate the names of the fields from its values.

It all worked fine as long as I was using a Server role, but it broke when using one of my users’ roles.

It all boils down to this:

Get(Index("MyIndex"))

I’ve tried adding the unrestricted permission to the role over the index (just to see what would happen) and it didn’t grant access to the index document.

Is there a way to overcome this limitation?

The Role will need read access for the Indexes() Collection.

Or in FQL:

CreateRole({
  name: "MyCustomRole",
  privileges: [
    {
      resource: Ref("indexes"),
      actions: {
        read: true,
      }
    }
  ],
  membership: []
})
1 Like

Awesome thanks again @ptpaterson !

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.