Questions tagged [typeorm]

TypeORM is an object-relational mapper for TypeScript and JavaScript that supports many different databases like MySQL and PostgreSQL and platforms like Node.js and the browser.

typeorm
Filter by
Sorted by
Tagged with
2 votes
1 answer
140 views

One-to-many relationship records are not updating correctly in postgresql

I have back-end server in nestjs with postgres and typeorm. The application is for small business for customize products in which admin can have products with basic info i.e name, description, cost, ...
0 votes
0 answers
11 views

I have a problem [Cannot read properties of undefined (reading 'signed_values')]

i need help around the create signed value and create signed data (i think that it needs to be async to wait for the signed data values to be created but i don't know exactly how to get around this) ...
3 votes
1 answer
79 views

TypeORM soft deleted link in junction table

I quite new to TypeORM and trying to use a many-to-many relation with help of a junction table (or "link table"). I am using soft deletes in my database – even on relation links in the ...
-1 votes
0 answers
13 views

How to make a base controller in Typeorm 0.3.17 and extends to other classes like mangoose [closed]

this base controller with generic CRUD operations like getOne, getAll, create, update, and delete. and this city controller enter image description here not use and extends function to base service ...
0 votes
0 answers
43 views

TypeORM How to get relation of relation with limit

I am trying to create a blog app with Typeorm and MySQL where I have 3 tables. Member, Posts and Images. Member has a One to Many relation to Posts and Posts has a One to Many relation to Images. I am ...
9 votes
5 answers
19k views

TypeORM cascade: true flag does not delete related entities

I can not figure out if it is me, of cascade: true option does not delete children entities when removing parent one? @Entity() export class Folder { @PrimaryGeneratedColumn() public readonly id:...
0 votes
0 answers
10 views

TypeORM findOne() security vulnerability

Is typeorm vulnerable with find one in this case ? const job = await this.jobRepository.findOne({ where: { id: task.jobId } }); This is issue reported by our SAST: "identifiers": [ { "...
0 votes
0 answers
15 views

Seeders to populate database

import { DataSource } from 'typeorm'; import { Seeder } from 'typeorm-extension'; import { User } from '../../user/entities/user.entity'; export class UserSeeder implements Seeder { async run(...
0 votes
0 answers
12 views

How to declare a Tree entity in TypeORM using JavaScript

I know that typeorm support tree entities and we can implement it in Typescript with decorator. But I wonder that is there any way to declare a tree entity in JavaScript? I have read the source code ...
0 votes
0 answers
24 views

TypeORM unaccent search without QueryBuilder

Does it exist a way to unaccent values in the database while searching a value in where condition without using QueryBuilder in TypeORM ? I didn't tried anything since no documentation or FindOperator ...
2 votes
3 answers
6k views

Why is FindOne where id using typeorm and mongodb doesn't work?

I am using typeorm with MongoDB. When I am searching for a document by Id with this syntax const manager = getMongoManager(); const user = await manager.findOne(User, {userId}); I got undefined result ...
0 votes
0 answers
14 views

How to return final response of query in Nestjs

I have API to get list of all the liked (favorite) requests and projects as below. So whenever we like request and later that request might get converted to project, so it should remain liked ...
0 votes
0 answers
9 views

Issue with TypeORM Many-to-Many with Custom Fields via One-To-Many

I have a Format entity and a Format Detail entity which has variables that can be assigned to one or more Formats. I also have a Format Detail Value entity which holds the value for a particular ...
0 votes
1 answer
2k views

Typescript TypeORM best way to create and save data

I'm currently working on a NestJS Project in which I have to store loads of data in a single database table. So I created an entity, a repository, a dto, and the route in order to store everything. My ...
3 votes
1 answer
644 views

Typeorm transaction without release

What happens if I start a commit transaction but don't release it? Example: const connection = getConnection() const runner = connection.createQueryRunner() await runner.connect() await runner....
-1 votes
0 answers
16 views

How to write "select" option in NestJS [closed]

I've write fullstack app with React and nestjs. But i'd an issue. In the client side, admin page i must to select year and drop the file, where file will be posted under the year which i choosed in ...
0 votes
0 answers
21 views

Nest.js TypeORM first request is too slow. Please help the masters [closed]

I'm developing a service using TypeORM for Nest.js, but the first request is slow. To sum up the current situation Queries run slowly for hours after application runs Normal operation If you make a ...
33 votes
10 answers
50k views

QueryFailedError: the column "price" contain null values - TypeORM - PostgreSQL

I've created a simple table: import { Column, Entity, PrimaryGeneratedColumn } from "typeorm" @Entity() export class Test { @PrimaryGeneratedColumn() public id!: number @Column(...
0 votes
0 answers
15 views

typeorm how to select without null in nested relations

I have tables users , roles , userRoles . I use Many-to-Many with custom fields and use softdelete. I have a problem when role is softdelete when i query (example below) user it have userRoles but ...
1 vote
1 answer
24 views

Retrieved time from NestJS with Typeorm not matched with record on Mysql DB

I use NestJs with Typeform on local matchine to retrieve updated_at, and created_at that are on Mysql DB. On DB, records are clearly stored in UTC, but after retrieve it using find() function. It has ...
0 votes
0 answers
37 views

How to detect offending field in "Unknown column 'NaN' in 'field list'" error

I have a TypeORM in Node.js project connecting to Mysql database. I am experiencing Unknown column 'NaN' in 'field list' error. The main question is how to detect the offending variable associated ...
0 votes
1 answer
419 views

How to describe a schema for many-to-many GraphQl relationships with custom properties?

How to describe a schema for many-to-many GrhapQl relationships with custom properties? Hi guys! I have the following tables: +-------------+--------------+----------------------------+ | ...
138 votes
29 answers
144k views

TypeORM Entity in NESTJS - Cannot use import statement outside a module

Started new project with 'nest new' command. Works fine until I add entity file to it. Got following error: import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm'; ^^^^^^ ...
0 votes
0 answers
15 views

TypeORM Entity Not Auto-Populating createdAt and updatedAt Fields on Insert Body:

I recently migrated an Express.js project from Sequelize ORM to TypeORM. In Sequelize, the createdAt and updatedAt fields were automatically managed without any issues. However, after switching to ...
0 votes
0 answers
12 views

How do I resolve module incompatibilities (nodejs application)? (.d.ts files differ)

I am having this annoying issue when attempting to build my nestjs application. > npm run build src/shared/infrastructure/event-store/events-bridge.ts:31:5 - error TS2322: Type 'ChangeStream<any,...
26 votes
5 answers
20k views

How do I prevent unwanted object properties from the client in nestjs while updating an existing row in mongodb

Creating a new user will ignore non-specified objects from create-user.dto.ts However when I update the user it will add unwanted fields like this: // update-user.dto.ts import { IsEmail } from '...
11 votes
16 answers
20k views

NestJS setup TypeOrm connection with .env and @nestjs/config

I'm trying to find the most legal way to set up NestJS database using .env file. That is I want to use @nestjs/config package for importing .env variables and use them in the TypeOrmModule. It seems I ...
0 votes
1 answer
198 views

TypeORM MongoDB aggregate

In my NestJS project I am trying to use aggregate but I cannot get it to work, and the documentation is very scarce. My entity looks like this: @Entity() export class MyItem { @Column() ...
0 votes
0 answers
20 views

TypeORM. Find where every field of the many-to-many relation is present in array

My goal is to find a chat where the field members includes every one of the IDs (basically an array of IDs) I'm getting from the frontend. The problem is that members is a many-to-many relation. In ...
0 votes
0 answers
16 views

TypeOrm transaction is causing error: current transaction is aborted, commands ignored until end of transaction block from PSQL

I've recently implemented transactional DB operations using the .transaction method. Sample snippet would be here: return entityManager.transaction(async (manager) => { await manager....
1 vote
1 answer
24 views

I don't know how to use DataSource instead of createConnection

CreateConnection and getConnectionOptions are deprecated as the typeorm version becomes 0.3.20. I know i have to use DataSource instead, but I can't modify it even if I look at the official document ...
0 votes
0 answers
13 views

nestjs pgsql typeorm is not updating the updated_at date nodejs

I am using nestjs with typeorm and i have created the following common entity, any other entity can extend this and have basic fields like created_at and updated_at but on updating/creating entry on ...
1 vote
4 answers
6k views

TypeScript: Module '"@nestjs/typeorm"' has no exported member 'TypeOrmModule' What is causing this?

I have installed all necessary packages to use typeorm for my mysql database but I keep getting Module '"@nestjs/typeorm"' has no exported member 'TypeOrmModule'. when I start my server. Why?...
-1 votes
1 answer
99 views

Nodejs application cannot communicate with postgresql (docker-compose)

I'm trying create a docker-compose file to connect a backend created in nodejs using typeORM to manipulate and connect with a postgresql database, but always is getting error. It's working in separete ...
0 votes
0 answers
44 views

EntityMetadataNotFoundError: No metadata for "User" was found

i have a nestjs project that i've published it with github actions and then i want to use the service of it in my other project for example (registerUser). but i am getting this error: ...
11 votes
4 answers
11k views

How to extend TypeORM repository in NestJS 9 (TypeORM 3.+)

Previously, TypeORM repository could be extended and injected directly into services, e.g.: import { User } from './entities/user.entity'; import { EntityRepository, Repository } from 'typeorm'; @...
0 votes
0 answers
30 views

"Cannot use import statement outside a module" error with [email protected] and [email protected]

The error Error during migration generation ... Cannot use import statement outside a module is frequently occurring when using TypeORM with TypeScript, but in my case this error starts to occur after ...
0 votes
1 answer
25 views

POST method with respective inherited class

How can I save a Meal expense within the method? The way to identify it is as follows in the service (expenses.service.ts) but when I tried to save it will save like a Expense (Parent Entity). async ...
0 votes
1 answer
13 views

Typeorm migration fails with `beforeInsert()`

I am on an ESM project where I have a db model that looks like this. My end goal here is to create an issuance record immediately when an application has been created. @Entity() export class ...
0 votes
1 answer
61 views

"Error: Could Not create constraint or index. see previous errors" with nest js and AzureSql

I am trying to use TypeORM with NestJS to make a migration in AzureSQL but the query failed in alter table to create FK. Below are the entities and errors: query failed: ALTER TABLE "procedure&...
4 votes
5 answers
15k views

How to union two tables in typeorm?

I want to union two tables in typeorm. First version: I crated sql raw queries, for each table const tableUn = this.tableUnion.createQueryBuilder('tu') .select('id') .addSelect('...
0 votes
0 answers
12 views

Use MoreThan between 2 columns

In a TypeORM project, I need to compare dates in 2 different columns in the database. So I guess I have to use the MoreThan operator but the doc only shows how to compare a fixed value, like MoreThan(...
0 votes
0 answers
22 views

Need guidance on implementing Multitenancy with NestJS, TypeORM, and PostgreSQL

I’m currently working on developing a Multitenancy application using NestJS, TypeORM, and PostgreSQL. My goal is to create a single database with multiple schemas for each tenant. However, I’m ...
3 votes
2 answers
2k views

How to create unique constraint with nullable field in TypeORM?

How to create unique constraint with nullable field in TypeORM? I used postgresql12, node v12.22.7. Is it better to create a separate raw query? Without a migration tool? If I use a raw query, can I ...
45 votes
6 answers
107k views

TypeORM: auto generated UUID in PostgreSQL

I am writing a REST API and for data access I am using TypeORM. I have used this successfully but I would like to have a UUID auto-generated primary key on one of my tables. Does anyone know how to ...
0 votes
1 answer
54 views

nest.js, method of extended repository is not a function

I'm new to nest, can't figure out what is wrong. I created an abstract base repository extended users repository from base implemented auth logic: controller service module auth service contains ...
0 votes
2 answers
71 views

How to combine response of 2 results using Node.js

The below code is to get the user list associated with particular id and this service.ts file. async getId(id:number){ //below code will give us participants list based on id let participants = await ...
0 votes
0 answers
27 views

Error: ENOENT: no such file or directory, read - TypeOrmModule

When runing pnpm run start:dev [14:35:56] File change detected. Starting incremental compilation... [14:35:56] Found 0 errors. Watching for file changes. Error: ENOENT: no such file or directory, read ...
0 votes
0 answers
35 views

Multi-tenant in micro-service architecture in NestJS using typeORM and Posgres

I want to design a multi-tenant microservice architecture in nest JS using typeORM and Postgres. I have found this article which is quite helpful https://thomasvds.com/schema-based-multitenancy-with-...
0 votes
0 answers
98 views

Nest JS providers mock issue

I am trying to test my Nest JS service. If I use @InjectRepository(Country) instead of @Inject(REPO_CONSTANTS.country) the test is easy to pass however I am looking for a solution for the existing ...

1
2 3 4 5
97