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 mysqlto create a directory calledtypeorm-playgroundcontaining your new project. You can replacemysqlwith 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
servicesexcept for the database you chose in step 2. (I've attached an example here of what the file should look like.) - Run
docker-compose upto start your database Docker image. - Open a new terminal window to run the remaining commands.
- Run
yarn installto install all your project dependencies. - Run
yarn startto run the playground project. It contains some example code with aUserentity 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.