2

I can create faunadb database with python API as follows:

client.query(q.create_database({ "name": "annuvin" }))

Also, I can create collection as follows:

client.query(q.create_collection({ "name": "spells" }))

So, how can I attach "spells" collection to the "annuvin" database? Thank you for your pointing!

ArunPratap
  • 4,816
  • 7
  • 25
  • 43
Ueda Takeyuki
  • 721
  • 10
  • 26

1 Answers1

2

In fauna documents are always scoped to the database of the secret that was used to create them. So you need to use create_key({"role": "server", "database": "annuvin"}) and use the returned secret with a fresh client. new_session_client is perfect for this. This will give give you a client to annuvin then you can proceed with creating documents inside of it.

benjumanji
  • 1,395
  • 7
  • 15
  • Thank you benjumanji, I've been succeeded! By the way, just for my reference, do you know where can I find that infos on the official document? – Ueda Takeyuki Sep 17 '19 at 12:12
  • https://docs.fauna.com/fauna/current/security/keys.html has the bit on keys being scoped to databases. I'm not sure if there are any docs that cover the session client stuff. I'll speak to our docs guy. Also see https://docs.fauna.com/fauna/current/tutorials/crud#database – benjumanji Sep 17 '19 at 14:11