How to bulk insert test data in Fauna DB?

Hello,

I want to create a Fauna DB and make bulk inserts with test data (create multiple documents in multiple collections) using a script like you do in an sql databases where you run an sql script.
For Fauna there are 2 ways of manipulating the data: using fql or using graphql.
I don’t necessarily want to use only the fql way.
I want to find the easiest and the most efficient way to do this.
For creating the database I think the easiest way is to use a graphql schema and import it
But to bulk insert test data into the db, I am not sure how to do it and what is the easiest way.

  1. Using FQL
  • I can use fauna shell and this command: fauna eval with an fql file but it does not support multiple fql queries inside the file

  • I can use fauna shell to run multiple fql queries but it’s a reusable approach.

  1. Using Graphql
  • I can create multiple mutations for creating the data and execute them in a http client (or maybe creating a script and parse it for every graphql request) like in the pic below but it takes too long and again it’s not a reusable approach.

If you notice some improvements that I can make to my approaches that would bring me closer to the expected result or if you already experienced other solutions for this problem I would appreciate verry much a reply to this topic!

Thank you!

Hi @ClaudiaGiv ,

I think this previous post may be useful - Bulk import?

Additionally, for the GraphQL example in general, you could use a JS library graphql-request to make graphql queries easy to create and send.

Hope that helps!

1 Like

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