Getting started
TypeORM is of course distributed as an npm package. You need to run npm install typeorm @nestjs/typeorm
.
You also need a TypeORM database driver; in this case, we will install the MySQL/MariaDB one with npm install mysql
.
TypeORM depends on reflect-metadata
as well, but luckily we had it previously installed as Nest.js depends on it too, so there’s nothing else for us to do. Keep in mind that you will need to install this dependency too if you’re using TypeORM outside of a Nest.js context.
NOTE: If you haven’t yet, it’s always a good idea to install Node.js: npm install --save-dev @types/node
.
Start the database
In order to get a database to connect to, we will use Docker Compose, with the official MariaDB Docker image, to set up our local development environment. We will point to the latest
Docker image tag, which at the time of writing, corresponds to version 10.2.14.
version
:
'3'
volumes
:
#
for
persistence
between
restarts...