Ueda Takeyuki
Ueda Takeyuki

Reputation: 871

How can I attach a collection to the database?

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!

Upvotes: 2

Views: 96

Answers (1)

benjumanji
benjumanji

Reputation: 1405

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.

Upvotes: 2

Related Questions