Open taki-tiler-server[bot] opened 1 day ago
Finish
In this step, you'll connect your code with the database and create your first table using only Typescript 😎.
Do we have libraries to access our database? Of course we do. We use ORMs to make our work easier by writing Typescript to perform queries to the database. We'd like you to use the same ORM that is used on the project you're going to work, , so if you don't know yet which ORM you should use, please ask your tutors. Some time ago, our main ORM was TypeORM. Now we are more focused on Prisma, but we always keep an eye on the trends so it can even be a third one.
docker-compose.yml
.start
code. For now, you can connect only with your local database, leaving the test connection for later.Note: don't forget to check if your docker container is running before connecting to the DB, otherwise it will fail.
Now you can ask: "Do they have a tool to manage the data inside the database without code?" Of course we do, young padawan. Actually, we recommend these two apps:
Feel free to choose one of these above, or any other app you want :D
After successfully connecting the ORM to your database, it's time to see it working by creating your first table. Guess what? It will be called User
(we told you so)
Note 2: too much for one step? Don't get stuck and feel free to ask anything to any Taqtiler 👍
Now open a pull request for your feature/setup-database
branch.
Step 1/4 - Containers everywhere
Estimated time: 2 hours
[Spoiler alert]: in the end of this onboard, you'll basically develop a CRUD of an entity called
User
. So, in order to store the user data in our app, let's create a real database.The database we use on most of our projects is PostgresSQL, an open-source relational database.
Creating the database containers
feature/setup-database
for the next 2 steps.There are a lot of setup so far right? In order to reduce the project setup time, we use Docker containers to create a database to work locally while developing. We'll create 2 databases: one for running server locally and another for (spoiler alert 2) the tests. Yeah, we will write tests. 🤓
First, make sure you have Docker installed on your machine. Just hit Command Space and type
Docker
. If not, you can download on their site.docker-compose.yml
file on your root project folder.docker-compose.yml
file. You can use this example if you want, just replace the values onenvironment
fields.$ docker compose up -d
on terminal to mount your containers.Note: Before run
docker-compose
commands, make sure that the docker is running on your mac. You can use again Command Space, typeDocker
and hit Enter.Note 2: If you want to stop your containers, you can run
$ docker-compose stop
command in your project's root folder.