Implement a free no-effort database for your next side-project.

Image for post
Image for post

Of course, everyone has. Most of the time, when we are trying out a new framework or language, one of the key things is data.

In this short example, you will notice how easy it is to create a secure database which can be accessed via a simple and straight forward Javascript SDK. The service we will be using is named Fauna.

So what is Fauna?

Fauna is a data API which creates a global data store for your application in a couple of minutes. The database has GraphQL support. Using FaunaDB will help you focus on your application and will handle scaling, sharding, provisioning, latency and correctness for you and maybe the most important part, it has a free tier!

How to set up your database

  1. Create an account at Fauna.
  2. Press new database.
  3. Choose a database name.
  4. (optional) toggle the Pre-populate with demo data toggle.
  5. Go to the Security tab and create a new key.
  6. Secure the secret in a separate file (we will use this secret).

Code time already?

Yes! As you can see, there were 6 simple steps to create a data API for our application. Now we can start using the faunaDB javascript client.

In the code snippet below you can find a simple example of fetching an User object from the user collection by id.

Image for post
Image for post
index.js
Image for post
Image for post
config.js

Interesting links

  1. Source code on Github.
  2. Plugin for the code snippets from VS code Polacode.

Consider using this service in your next side project and let me know your thoughts on FaunaDB.

Originally published at https://dev.to on October 17, 2020.

Passionate Javascript/Typescript developer | Clean code fanatic | Trying to become a productivity guru | Sharing knowledge is part of the process

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store