Node.js with TypeORM.

Edison Devadoss
2 min readNov 23, 2019

--

Hi Friends, In this article, I will explain about node js with TypeORM.

I will write node.js with TypeORM multiple parts.

google image

PART 1

For part 1 I cover only initial setup. Before I explain about the initial setup. I will give a simple introduction to TypeORM.

What is TypeORM.

TypeORM is specifically an ORM that converts data between JavaScript / TypeScript to a variety of databases: MySQL / MariaDB / Postgres / SQLite / Microsoft SQL Server / Oracle / sql.js.

More detail about TypeORM

ORM is Object-relational mapping.

Initial setup.

Install globally

$ npm install typeorm -g

Create a project

$ typeorm init --name graphql-ts-server-boilerplate --database postgres

In your ormconfig.json file set your DB collection.

https://carbon.now.sh/

In the above picture, I edited the username, password, database. We should create a database in Postgres. Install Postgres in your device.

Update tsconfig.json file from this link.

https://carbon.now.sh/

Create tslint.json file and update from this link.

https://carbon.now.sh/

Install dev dependencies.

$ npm install --save-dev tslint tslint-config-prettier nodemon

Set nodemon in your package.json.

$ "start": "nodemon --exec ts-node src/index.ts"

Run npm start

$ npm start

If your DB connection established successfully, npm start successfully.

Then setup graphql-yoga.

$ npm install graphql-yoga

Once you installed successfully edit index.ts file.

https://carbon.now.sh/

Finally, run the code.

$ npm start

It will open http://localhost:4000/

Local image

--

--

Edison Devadoss
Edison Devadoss

Written by Edison Devadoss

Software Engineer / Full Stack Developer / JavaScript / React / React Native / Firebase / Node.js / Book Reader

No responses yet