Skip to main content

Questions tagged [nestjs-typeorm]

The tag has no usage guidance.

nestjs-typeorm
Filter by
Sorted by
Tagged with
7 votes
0 answers
262 views

Does TypeORM incorrectly infer return type when findOne function has specific "select" input?

Here, the Quiz entity has @ManyToOne (decorator) relation to Author entity. The Author entity has many properties like id, name, age, not just id. If I do not pass the select option in the input of ...
leodevbro's user avatar
  • 153
5 votes
1 answer
373 views

Access execution context metadata in regular providers

I'm using nestjs for a simple HTTP rest API, with typeorm. I have 2 Postgres databases, and I want to be able to access both, But it doesn't have to be at the same time. Basically, I want to set which ...
CY-OD's user avatar
  • 451
3 votes
2 answers
2k views

NestJS Repository gives error 'No metadata for "TaskRepository" was found.'

GitHub link to project: nestjs-task-management Error Log: [Nest] 15824 - 23/08/2023, 11:22:29 LOG [NestFactory] Starting Nest application... [Nest] 15824 - 23/08/2023, 11:22:29 LOG [...
SAIF ALI's user avatar
3 votes
1 answer
229 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 ...
Jonas's user avatar
  • 31
3 votes
1 answer
476 views

Nestjsx Crud library - cannot read properties of null (reading 'parsed')

I'm having trouble setting up the Nestjsx Crud library on a brand-new project. I followed the "Getting Started" steps defined in the library's docs linked here [Nest] 23136 - 08/24/2023, 11:...
Ilija Vuk's user avatar
  • 353
3 votes
2 answers
1k views

how can i generate a migration using TypeOrmModule.forRootAsync as the DataSource?

Trying to integrate migrations in a nest.js project I ran the migration:create command from typeorm and there was no problem, but when I try to generate a migration with migration:generate like this: ...
Joel Ochoa's user avatar
2 votes
1 answer
845 views

TypeORM: "No migrations pending" on windows 11

I have one nestjs app where I'm using typeorm, PostgreSQL . This app is working fine on linux/mac os. But in windows 11, no data found on migration table, that's why no table is created on PostgreSQL ...
sabbir's user avatar
  • 2,005
2 votes
1 answer
560 views

Migration scripts for nx nestjs typeorn

I am working with nx with typeorm and nestjs and I am Unable to generate migration Here is my migration script db.config.ts export const dataSourceOptions: DataSourceOptions = { type: 'postgres', ...
suraj gupta's user avatar
2 votes
1 answer
26 views

Typeorm with ManyToMany relation deletes data while updating

I have a ManyToMany relation with a pivot table, when I try to append new values including old values, Typeorm deletes old ones. export class VHost { //.... } export class Migration { @Column({ ...
abdelmac's user avatar
2 votes
0 answers
863 views

How to properly define/configure Drizzle ORM in Nestjs Application

I am new to Nest and am trying to properly define the modules, services and provider. I dont seem many examples and of the one i have seen, it does not appear to be defined properly. I am looking to ...
Don's user avatar
  • 421
2 votes
1 answer
323 views

TypeError: relatedEntities.forEach is not a function in NestJS/TypeORM

Since I write using Google Translate, the sentences may be awkward. I wrote the following code to store data in a table using a foreign key: async createGroup(tokenDto: tokenDto, createGroupDto: ...
Xii's user avatar
  • 21
2 votes
0 answers
118 views

E2E tests that include database transactions fail randomly

I'm using TypeORM for PostgreSQL in my NestJS project. For E2E tests, that have requests that do transactions, fail randomly. I added a timer after the transaction request of 50ms. After that, it ...
cyclonejet's user avatar
2 votes
0 answers
366 views

Nest.js TypeORM - How to run same migration in different schema?

I am working on multi-tenant application where each tenant has different schema. example schemas: public (default) tenant_001 tenant_002 I am able to run migrations on public schema. But unable to ...
Aravin's user avatar
  • 6,909
2 votes
1 answer
3k views

TypeORM: Implementing "WHERE NOT EXISTS" clause in querybuilder

In TypeORM, I am trying to create a query builder to generate the following Postgres query: SELECT "mt"."id" AS "id" FROM "main_table" "mt" WHERE &...
billshortz's user avatar
2 votes
0 answers
724 views

Can you join multiple columns in typeorm where one is a fixed value and the other is the ID?

I have a child field that's the same for two entities. I want to join using "parent_id" which points to one of the two entities and "parent_type" indicating which entity type. How ...
Fred Johnson's user avatar
  • 2,637
2 votes
1 answer
2k views

How to insert slug automatically by tiitle using typeorm?

I am new in typeorm. I am already complete many part in practice. But Now I am facing confused because I am not getting any docs or blogs about creating and updating an unique slug by title in typeorm....
Md Ali's user avatar
  • 257
2 votes
1 answer
1k views

Nest JS application is not starting with TypeORM 0.3 Datasource method TypeORM (0.3.10)

I have a Nest JS application using TypeORM 0.3 version. The application is not starting with the new DataSource configuration. Error: Nest JS application is not starting with Data source new typeORM 0....
Amir Mustafa's user avatar
1 vote
2 answers
3k views

NestJS TypeORM createQueryBuilder SELECT query

I am trying to run a query SELECT USER_CODE FROM USERS using TypeORM in nestJS. My database is MySQL and this database has a users table with the columns: 'USER_CODE', 'USER_EMAIL', 'USER_PASSWORD',...
tonykrjhc's user avatar
  • 141
1 vote
2 answers
184 views

How to get the users with latest post in a single query in typeorm

I am using nest.js + typeorm + mySql here are my entities @Entity() export class User { @PrimaryGeneratedColumn('uuid') id: string @Column() name: string @OneToMany(() => Post,...
Lalit Kumar's user avatar
1 vote
1 answer
385 views

Indicate that a column should be indexed with TypeORM's entity schema files

I'm using TypeORM with entity schema files and I need to indicate that an index needs to be created on a column. If I were using decorators, I could simply do: @Entity() class Foo { @Index() @...
user1870238's user avatar
1 vote
1 answer
297 views

How to make a projection with TypeOrm's MongoRepository

I'm using NestJs with TypeOrm and I need to make a projection from one of my collections: I want to query all documents but I just need 2 fields per document. This can be done with Mongo (docs db....
Jeanluca Scaljeri's user avatar
1 vote
1 answer
1k views

No migrations are pending using Typeorm CLI and NestJS

The issue I'm facing is with running migrations using @nestjs/typeorm ^9.0.1 and typeorm ^0.3.12. Despite being able to build the project and create migrations, when I try to run them, typeorm can't ...
charlescol's user avatar
1 vote
1 answer
109 views

TypeOrmModule in Nest causes controller params to be undefined

In my Nest js app, This is the code of the app.controller: @Controller('app') export class AppController { constructor(private readonly appService: AppService) {} @Get('/:id') getHello(@Param('...
moshi's user avatar
  • 294
1 vote
1 answer
309 views

Why do I need to import Entities separately instead of just the Module in NestJS?

I have a NestJS application consisting of modules, each with its own services, controllers, and entities. Why do I need to import all the required entities directly from various modules into other ...
itinance's user avatar
  • 12.2k
1 vote
1 answer
846 views

How to fix DateTime- and TimeZone- issues between PostgreSQL and a NodeJS/NestJS application?

I have a Postgres database and a nodeJS application (NestJS framework, for the sake of completeness). And I need help with timezone issues. This is my table storing blog posts: create table if not ...
delete's user avatar
  • 18.9k
1 vote
1 answer
682 views

How to mock `createQueryBuilder` in NestJS tests?

I have this NestJS service method which I need to test. async getAllTests(orgId: string): Promise<Array<TestEntity>> { try { const query = this.repo.createQueryBuilder(this.tableName)...
Chris Barr's user avatar
1 vote
1 answer
615 views

TypeORM group by based on date only, ignoring time

I want to group my data based on only the createdAt date part ignoring the time, but i can't figure out how to. Here's my code, which groups the data by date as well as the time component of createdAt:...
mechaadi's user avatar
  • 673
1 vote
1 answer
2k views

implementing clean architecture in NestJS

recently I started a personal application using Angular 16 and NestJS as backend. I'm newbie with these technologies and I like all related with design patterns and architectural styles, so I would ...
Aldemar Cuartas Carvajal's user avatar
1 vote
1 answer
254 views

Unit Test doesnt prevent running any of the transactional code in unit tests

U've add the decorator @Transactionnal in my service method, all works fine, i follewed this documentation Typeorm Transactional My project works perfectly, also e2e tests, but coming to unit test the ...
Mirlo's user avatar
  • 664
1 vote
1 answer
290 views

Typeorm eager load with a condition for the children

I have two entities, one parent and one child. There is a OneToMany relation with eager enabled. When I get the parent entity I would like to load only children with the property deleted to false. For ...
Gregory Boutte's user avatar
1 vote
1 answer
1k views

In typeORM, 'transformer' is triggered even though the value of the model being targeted for the relationship is 'null'

when I use the property 'eager' for a relationship in typeORM, 'transformer' is triggered even though the value of the model being targeted for the relationship(name: Withdrawal) is 'null'. What can I ...
Jay-flow's user avatar
  • 187
1 vote
1 answer
491 views

TypeORM - Foreign key without constraint and reference

I'm developing a backend app using Nest.js with an existing MariaDB database and I'm using TypeORM. I can't alter the production database table but can read from it. So I have separate development DB ...
Zoka's user avatar
  • 435
1 vote
1 answer
2k views

How to setup migrations along with ConfigModule in Nestjs

I am trying to figure out a way to setup migrations with typeOrm 0.3.12 in Nestjs along with ConfigModule.The database to be used in this project is Postgres. I have two problems: When trying to ...
codeless's user avatar
1 vote
1 answer
26 views

TypeORM embedded entity shorthand select?

Recently, I got stuck scratching my head, because of how TypeORM behaves, given entities: class Event extends BaseEntity { location: Address } class Address { @Column({ type: 'varchar' }) ...
ggat's user avatar
  • 472
1 vote
1 answer
36 views

Dependency injection in Nestjs is working on the controller but no the service

I'm working on an existing NestJS project with TypeORM to manage a PostgreSQL database. I have a ReclamoService in a ReclamoModule that I want to use in the UsuariosService of a UsuariosModule. When I ...
Eduardo Serrano's user avatar
1 vote
0 answers
55 views

TypeORM Error when using camel case alias in addSelect

I'm using TypeORM and Postgresql .I have 2 entities event and eventParticipant relationship is one-to-many. I want to sort by the number of eventParticipants with booking status so I used addSelect ...
Vương's user avatar
  • 11
1 vote
0 answers
49 views

Nestjs Discriminators

I have a Discount Model that has a dynamic property type which can be one of three Models (Vegetable or Bread or Beer), after taking a look at Nest’s official documentation, I believe that by using ...
Oussama Bouchikhi's user avatar
1 vote
0 answers
226 views

Interface and model in TypeScript (angular 17)

Can someone help me with my code? This is the Articlefournisseurs model: import { Conditionnement } from "./conditionnements"; // import { IntefaceConditionnements, IntefaceConditionnement } ...
Mika Raveroson's user avatar
1 vote
1 answer
391 views

Nestjs/Jest Is there a way to override Module in imported Module in e2e test

Im writing an e2e test for my api. To implement e2e test i have to use AppModule in imports when creating TestingModule: beforeAll(async () => { const module = await Test.createTestingModule({...
DanilMakarov's user avatar
1 vote
0 answers
315 views

How to link supabase table with foreign key to User Data, using NestJS and typeorm?

I just create a Supabase DB using NestJS and TypeORM. I have some entities like this: @Entity() export class UserService { @PrimaryGeneratedColumn() id: number; @OneToOne(type => User)...
queng's user avatar
  • 49
1 vote
1 answer
92 views

Why is TypeORM andWhere breaking my query

I have a very simple query. Media has a relationship with users. The media table has a column userId. I am attempting to do a search on title and description, but only after I get the media for the ...
Aaron's user avatar
  • 2,542
1 vote
0 answers
324 views

One To Many relationship properties not functioning as expected. Cannot Retrieve List of Members from Group records - NestJS TypeORM

Is there anyone willing to help me understand TypeORM and Nestjs? I keep getting this unbearably annoying error "Cannot read properties of undefined (reading 'id')" and I'm sure it has ...
JustinD's user avatar
  • 25
1 vote
0 answers
80 views

Persistent Database Unresponsiveness Issue in NestJS Production Environment

I'm encountering problems with my NestJS (TypeOrm) application. In the production environment, after a certain period, the database becomes unresponsive. This issue persists until I restart the server....
gaiyaobed's user avatar
1 vote
0 answers
136 views

ER_CON_COUNT_ERROR: Too many connections Typeorm nestjs

i am using raw query to execute the command and it is running but i am having a problem because every time it is executed it always creates a new connection, so i get the error "...
riski's user avatar
  • 15
1 vote
0 answers
23 views

Nest can't resolve dependencies of the UsersLineService (UsersLineRepository, HttpService, ?)

Error [Nest] 20898 - 07/23/2023, 6:09:36 PM ERROR [ExceptionHandler] Nest can't resolve dependencies of the UsersLineService (UsersLineRepository, HttpService, ?). Please make sure that the ...
1 vote
0 answers
149 views

Type 'string' is not assignable to type 'never' when using $push on sub-document array with getMongoManager updateOne

I am trying to execute the following code snippet to update a sub-document array using the $push operation with getMongoManager's updateOne method from myEntity.service.ts: import { getMongoManager, ...
Sadaf Sid's user avatar
  • 1,570
1 vote
1 answer
295 views

Error: Nest can't resolve dependencies despite adding the module to imports

This is my owners.service.ts import { Injectable } from '@nestjs/common' import { CreateOwnerInput } from './dto/create-owner.input' import { UpdateOwnerInput } from './dto/update-owner.input' import {...
nikulas13's user avatar
  • 177
1 vote
0 answers
972 views

TypeORMError: Driver not Connected - NestJs

I am setting up a NestJs application with TypeORM and postgres driver. I have the required packages needed ("pg": "^8.11.0" and other typeorm packages). data-source.ts import '...
nirvair's user avatar
  • 4,150
1 vote
0 answers
184 views

TypeOrm in NestJS: Single Table Inheritance Repository not returning properties of most specific type

Currently I'm having the following Structure: I have an abstract class AocMessage with properties such as received, from and to. In addition I have class FreetextMessage that extends the abstract ...
Mischa Binder's user avatar
1 vote
1 answer
650 views

NestJs With TypeORM(0.3x) Custom Repository Transaction Problem

I am using NestJs by creating a custom repository as follows. iuser.repository.ts import { UserEntity } from "../entity/user-entity"; export interface IUserRepository { findByEmail(...
Jonathan's user avatar