This guide is intended for people who'd like to experiment with TypeORM in a hands-on fashion. I find this especially helpful when attempting to construct complex queries.
You need Yarn and Docker installed.
- Install TypeORM globally using
yarn global add typeorm
. - Run
typeorm init --name typeorm-playground --database mysql
to create a directory calledtypeorm-playground
containing your new project. You can replacemysql
with the database of your choice. - Move into the directory you created using
cd typeorm-playground
. - Visit this docker-compose.yml file in the TypeORM GitHub repo. Copy it into your playground project directory. Remove every section under
services
except for the database you chose in step 2. (I've attached an example here of what the file should look like.) - Run
docker-compose up
to start your database Docker image. - Open a new terminal window to run the remaining commands.
- Run
yarn install
to install all your project dependencies. - Run
yarn start
to run the playground project. It contains some example code with aUser
entity and some simple queries against it. - Press CtrlC to exit the project.
That's it! Now you can edit the src/index.ts
file to play around with different queries.