fauna / faunadb-ruby

Ruby driver for FaunaDB

Home Page:https://fauna.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

client should allow creation of a new context to switch keys.

freels opened this issue · comments

Since FaunaDB API access relies on keys to switch perspectives, it should be easy to temporarily do so with a client. For example:

client = Fauna::Client.new(secret: SERVER_KEY)

user_token = client.query do
  login ref('users/123'), password: 'sekrit'
end

user_client = client.with_secret(user_token[:secret])
user_client.query do
  paginate match(ref('indexes/items_by_user'), ref('users/self'))
end