FQLv10 and attaching indexes to schema documents

Hello,

Is there a way to attach indexes to built in collections, like Key, in FQLv10? I use AWS SecretsManager to store and rotate Fauna keys, and the code relies on being able to query a custom index to find the key created by the SecretsManager rotation. This uses a field called “token” which is populated in the key’s metadata when creating it.

fauna_client.query(
    query.create_index(
        {
            "name": "unique_keys_by_token",
            "source": query.keys(),
            "terms": [{"field": ["data", "token"]}],
            "unique": True,
        }
    )
)

It is not currently possible to define indexes on system collections (e.g. Key, Token, Collection, etc.) in FQL v10.

What you can do is create a Collection to store references to the keys.

Collection.create({ 
  name: "SecretsManager",
  indexes: {
    byToken: {
      terms: [{ field: "token" }],
    }
  }
})
// generate the key
let key = Key.create({ /* ... */})

// store a reference to the key
SecretsManager.create({
  key: key,
  token: /* ... */
})

// return the key to the caller
key

Is it planned to add the ability to add indexes to system collections to regain parity with FQLv4 in the future?

At this time, we do not have any plans to add user-defined indexes on system collections for FQL v10.

That’s unfortunate. There might be more use cases besides mine for system collection indexes. I can think of a multi tenancy scenario where one might need to look up a child database based on some metadata. That was easy to implement in FQLv4 as an index could use any collection as a source, system or otherwise.

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