Database Hub

Connect to a Database

6min

Connect to a Database

Introduction

Connecting a Database using the Database Hub allows you to have access to the source database structure and data from inside your App in Back4app.

This ensures any new updates for schemas and/or data are immediately delivered to your App so everything is up to date at any given moment.

This is also useful when big (a.k.a. in huge) databases are available, allowing you to use its data without having to fully copy the database to your account.

Prerequisites

In order to use or share a database, you will need:

1 - Find a Database to connect

Go to the Database Hub list of databases and search for any topic that interests you.

For this tutorial, will be used the Database of World Continents, Countries and Cities:

Document image


2 - Connect

Click the Connect button on the top right corner of the screen. The counter on the right side shows how many Apps are using that database at the moment:

Document image


The Connect dialog will appear. Then choose to which App, from one of your already existing apps, you want to connect. The chosen App in the drop down will have access to the Database that you are connecting to.

Document image


Then, success message will appear:

Document image


3 - Use the data

Go to the Dashboard of the App you connected. You will notice the classes from the connected Database appear in the Database Browser in the following formats:

DatabaseName_ClassName if it is a custom class DatabaseName__ClassName if it is a Parse class

The difference is that Parse classes have two _ between the DatabaseName and ClassName:

Document image


From now on you can query the data of the connected classes on your code, the API Console, the GraphQL console and even make relations and pointers among your App’s classes and the connected ones.

Document image




Updated 28 Mar 2024
Did this page help you?