#7301·typeorm

Create FindOrCreate metod

Author: andreghisleniCreated Jan 20, 2021Updated Sep 16, 2026
Labelsfeaturecomp: repositorygood first issue

Feature Description

One method to find or create. Does not create a new record if exists one register. Does create a new record if not exists one register.

The Problem

I'm always frustrated when need to create or search a record, requiring more than one request in the database.

The Solution

Create a method to find one register in case don't find, make a register in table.

Considered Alternatives

Additional Context

Relevant Database Driver(s)

  • aurora-data-api
  • aurora-data-api-pg
  • better-sqlite3
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • sqlite
  • sqlite-abstract
  • sqljs
  • sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

  • Yes, I have the time, and I know how to start.
  • Yes, I have the time, but I don't know how to start. I would need guidance.
  • No, I don't have the time, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.