Overview of ORM Database Tools

Andre Vianna
My Dev Zone
Published in
3 min readJan 20, 2022

Object Relational Mapping (ORM)

Summary

  1. Concepts of ORM
  2. Prisma ORM
  3. Type ORM
  4. Sequelize ORM
  5. Micro ORM

References

1. Concepts of ORM

Object-Relational Mapping (ORM) is a technique that lets you query and manipulates data from a database using an object-oriented paradigm. When talking about ORM, most people are referring to a library that implements the Object-Relational Mapping technique, hence the phrase “an ORM”.

An ORM library is a completely ordinary library written in your language of choice that encapsulates the code needed to manipulate the data, so you don’t use SQL anymore; you interact directly with an object in the same language you’re using.

Postgres Installation with Docker

docker run --name postgresql -e POSTGRES_PASSWORD=admin -p 5432:5432 -d postgres

Prisma Migrate

yarn prisma migrate devcreate productcreate categorycreate product_category

Prisma Studio

yarn prisma studio

Prisma Relations

HTTP/1.1 200 OKX-Powered-By: ExpressContent-Type: application/json; charset=utf-8Content-Length: 150ETag: W/"96-UrprlteTTnqfmSPc6+2Svgk22kw"Date: Thu, 20 Jan 2022 17:45:34 GMTConnection: close{"id": "70df8552-3b15-4532-ba10-084018283e17","id_product": "1d8da63e-c4dc-43e5-87b1-ddf1699dd7f1","id_category": "130b29d6-563b-4a73-8c2e-fe1c737ef99c"}

Create a Product with Category

import { Request, Response } from "express";import { prismaClient } from "../database/prismaClient";export class CreateProductWithExistCategory {async handle(request: Request, response: Response) {const { name, price, bar_code, id_category } = request.body;const product = await prismaClient.productCategory.create({data: {product: {create: {bar_code,name,price,},},category: {connect: {id: id_category,},},},});return response.json(product);}}

4. Sequelize ORM

--

--

Andre Vianna
My Dev Zone

Software Engineer & Data Scientist #ESG #Vision2030 #Blockchain #DataScience #iot #bigdata #analytics #machinelearning #deeplearning #dataviz