Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
12 views

In NestJS, service is invalid when injected to another service?

I`d like to develop a rest app by NestJS and MikroOrm. And I prefer to use clean architecture to manage code, so a lot of modules are abstracted and a module need to be import to another module. What ...
Li Zhenxin's user avatar
0 votes
0 answers
29 views

Mikro ORM - How to sort by the appropriate field type on a json field?

I currently have a table with a json field on it, which we use to store metadata. I have the following model: @Embeddable() class Meta { @Property({ nullable: true }) foo: string @Property({ ...
plusheen's user avatar
  • 1,374
0 votes
1 answer
98 views

MikroORM CLI Error: No database specified, please fill in `dbName` or `clientUrl` option

Trying to get the MikroORM CLI running, but no luck. I have NX monorepo with MikroORM being a library. I have tried with .env variables and with package.json but getting different errors for them. ...
z0mbieKale's user avatar
0 votes
0 answers
81 views

How to provide fresh instance of Mikro ORM entity manager into repositories during testing?

I am trying to test my command handler which has multiple repositories injected into it. When running the test I am getting the following error: ValidationError: Using global EntityManager instance ...
z0mbieKale's user avatar
0 votes
1 answer
102 views

Mikro-orm: Update with select statement

I am trying to update a table column that is dependent on one more table. The sql query is working fine on database and couldn't figure out the mikro-orm query for that. Below are the sql and mikro-...
mc-user's user avatar
  • 1,965
0 votes
0 answers
35 views

How to properly unit test a class with Mikro ORM and NestJS?

I have a service called PackageCalculator @Injectable() export class PackageCalculator { private readonly logger = new Logger(PackageCalculator.name); private doesPackagesMatch(packageDosages: ...
z0mbieKale's user avatar
0 votes
1 answer
196 views

Cannot run Mikro-ORM migrations on bun

I'm currently running an all-typescript project with Bun + Elysia. I've migrated my app from a previous NestJs project, which was running MikroORM just fine. Now that I've had my app running via bun, ...
Reza Hajianpour's user avatar
0 votes
0 answers
47 views

Mikro ORM migration error: The "path" argument must be of type string. Received undefined

I'm trying to set up an integration test and need to migrate the db to the latest but got this error: const orm = await MikroORM.init(options); await orm.getMigrator().up(); // this line cause the ...
Sỹ Lê's user avatar
  • 133
0 votes
0 answers
34 views

adminJS shows raw IDs instead of actual data (using mikroORM and postreSQL)

I am using TypeScript, mikroORM, postreSQL and adminJS. Trying to achieve the actual data being displayed instead of its raw IDs. I have two entities: @Entity({ tableName: 'professors' }) export class ...
m4d_h4tter's user avatar
0 votes
0 answers
17 views

Should MikroORM be injected into a builder class or should it be integrated into a repository for the same service?

I have a builder class which I simplified below: interface Builder { setTitle(title: string): BookBuilder; ... // sets a bunch of attributes here build(): Book; } class BookBuilder ...
21march's user avatar
-1 votes
1 answer
64 views

Issue while saving time without timezone in PostgreSQL

I'm encountering an issue when trying to insert a time value into a field defined as startTime in my entity in PostgreSQL. Here's the relevant code: @Property({ type: 'time' }) startTime!: Date; And ...
Athulya Ratheesh's user avatar
1 vote
1 answer
69 views

Mikro Orm v6 .raw function doesnt exist in createQueryBuilder

I am having an issue with the upgrade to mikrOrm v6 and cannot find any documentation on what I can do to upgrade. I keep getting an error for qb.raw doesnt exist on createquerybuilder. Is there an ...
Dale's user avatar
  • 65
0 votes
0 answers
36 views

Type 'E' does not satisfy the constraint 'object'

This error is throwing after upgrade the node version to 20. In node version 16 it was work perfectly error TS2345: Argument of type 'E' is not assignable to parameter of type 'Partial | Partial[]'. ...
Muditha's user avatar
  • 193
0 votes
1 answer
169 views

mikroorm postgresql setup error with type

So i'm trying to setup a mikroorm with postgresql, but I get this weird error on the type: This is the code import { MikroORM, Options} from "@mikro-orm/core"; import { _prod_ } from "./...
Vinz Lorenz's user avatar
-1 votes
1 answer
43 views

How do I import a type definition from a module in JavaScript+JSDoc?

I am trying to import a type definition from a module in JSDoc into my SvelteKit application. This is the TypeScript code I'm trying to implement as JS/JSDoc: import type { PostgreSqlDriver } from '@...
Daniel's user avatar
  • 3,385
0 votes
1 answer
90 views

MikroORM update coallesce

In MikroORM, what would be the best/efficient way to implement update for specific values that are NOT NULL? For example, in Postgres there is the COALESCE() function: UPDATE some_table SET ...
GoldenLab88's user avatar
1 vote
1 answer
215 views

How to run E2E testings with Nest.js and MikroORM?

So, I have this Nest.js API app that use SWC and Vitest. Here are the minimized files of Users module. CRUD users service: // users.service.ts ... @Injectable() @UseInterceptors(...
Swix's user avatar
  • 2,023
1 vote
1 answer
176 views

Nestjs with MikroOrm can't inject Entity Manager

I'm using an nx monorepo with NestJS and MikroORM. I've create a module called PersistanceModule that is defined like this: import { Module } from '@nestjs/common'; import { MikroOrmModule } ...
joseFrancisco's user avatar
1 vote
1 answer
105 views

MikroORM - Non-FK'd ID conditional join

I have inherited this strange database schema, where there's a jsonb field, and on that json is a userId, and userType. There are also two user tables, representing different user types. The table ...
plusheen's user avatar
  • 1,374
0 votes
1 answer
85 views

How to only discover said entities instead all?

I'm using Mikro-orm (6.1.5) in serverless functions with a shared db package where I keep all my entities. Since the app started to get bigger I noticed a slow down and realised all my entities were ...
mihristov's user avatar
  • 354
0 votes
0 answers
29 views

MIKRO ORM: Load only the nested entities that fit the criteria

I have a series of nested entities that works like that: queryBuilder .select(`*`) .joinAndSelect('project.segments', 's1', undefined, 'innerJoin') .joinAndSelect('s1....
vicebas's user avatar
-1 votes
1 answer
28 views

How to order the query through the greatest updatedAt on a nested one to many entity

I have a series of nested entities that works like that: Entity1 -> Entity2 -> Entity3 ( With arrows representing a one to many relationship) Im using MikroORM. How can i write a findAndCount ...
vicebas's user avatar
0 votes
0 answers
279 views

in mikroorm when I try to insert record it do update statement

I am try to use mikroorm with nest js import { Migrator } from '@mikro-orm/migrations'; import { defineConfig } from '@mikro-orm/postgresql'; import { TsMorphMetadataProvider } from '@mikro-orm/...
Mohamed Magdy's user avatar
0 votes
0 answers
162 views

Get all entities where the string array property contains the input string (MikroOrm + TypeScript)

I'm trying to make a MikroOrm query in Typescript that gets all Movies which belong to a specified inputGenre. Each Movie has not one, but an array of genres associated to it. So if I have the ...
Andrei Statescu's user avatar
2 votes
0 answers
184 views

MikroORM cannot find module using absolute paths for importing

I am using NestJS with TypeScript and MikroORM with the MikroOrm-configuration { ... entities: ['dist/db/entities'], entitiesTs: ['src/db/entities'], baseDir: process.cwd() // default ...
Azus Dkk's user avatar
  • 115
0 votes
1 answer
83 views

Mikro-ORM nested collection type safe access

I am unable to access properties of a nested loaded entities. I have the following structure Treatment OneToMany TreatmentCycle TreatmentCycle ManyToOne Physician Physician ManyToOne User User ...
z0mbieKale's user avatar
0 votes
1 answer
127 views

How to define an array in Mikro-ORM abstract base entity?

I am trying have an array with domain events in my Mikro-ORM abstract entity, but after retrieving the entity from persistence (repository) it is undefined. Is there a way to make it initialized after ...
z0mbieKale's user avatar
0 votes
1 answer
206 views

MikroORM referenced entity JSON value

I don't know if this is a bug or correct behavior, but when I return json from an entity that has a reference Ref to @ManyToOne entity I get "city": "bd612c71" for that reference, ...
z0mbieKale's user avatar
1 vote
1 answer
346 views

How to properly use MirkoORM custom repository with NestJS?

When registering entities through MirkoORM.forFeature() method it automatically registers the repositories if I have the entity properly set up. This is an example entity I have @Entity({ ...
z0mbieKale's user avatar
0 votes
1 answer
254 views

How to extend custom BaseRepository with Mikro ORM EntityRepository

I am trying to create a BaseRepository with custom methods that every repository should have. I have created my custom repository and extended it with EntityRepository but I get TS warning when trying ...
z0mbieKale's user avatar
0 votes
1 answer
310 views

I can't read env values in mikro-orm.config.ts

I use mikro-orm in nest js, and i write mikro-orm.config.ts with using configService.get(). But it doesn't get env value. Process.env is too. In other files like main.ts, it can get env properly, but ...
saltwoodYJ's user avatar
0 votes
1 answer
147 views

Nestjs Mirko-orm through exception with no trace

Im stuck trying to identify where this error is in my nestjs application. Anyone have any ideas or options I can add to get more info? [Nest] 8792 - 06/10/2023, 3:32:29 pm ERROR [...
Dale's user avatar
  • 65
0 votes
0 answers
203 views

Mikro-ORM Keeps Generating Unwanted Migrations for text[] Column Type in NestJS

I'm using NestJS along with Mikro-ORM and PostgreSQL for my project. I've run into an issue where Mikro-ORM continuously generates migration changes for certain fields even when there are no changes ...
Philipp Schöler's user avatar
0 votes
1 answer
720 views

MikroORM jest unit test - how to provide entity repository with connect: false

When I use MikroORM.init() in unit test I want to use connect:false option to not create db connection, but test the entity behaviour for example more complex update method like: "wrap(...
Chriss's user avatar
  • 21
1 vote
1 answer
507 views

Common Table Expressions - is there a way to do them in MikroOrm?

Is there a way (even a hacky way) to do common table expressions with MikroOrm? I've searched all over and can't even find any post mentioning it whatsoever.
synic's user avatar
  • 26.6k
0 votes
1 answer
235 views

In mikro-orm, Is it possible to track unit of work changes in the afterTransactionCommit hook in explicit transactions?

In afterFlush event we receive the changes in entities seeing uow arg: async afterFlush(args: FlushEventArgs): Promise<void> { args.uow?.getChangeSets()... But in afterTransactionCommit ...
Miguel Garcia's user avatar
0 votes
0 answers
279 views

MikroORM: "must appear in the GROUP BY clause or be used in an aggregate function"

I have the following query set up using the QueryBuilder: return this.qb('user') .where({ id }) .leftJoin('user.transactions', 'transactions') .leftJoin('user.wallet', 'wallet') ...
Bowis's user avatar
  • 610
0 votes
1 answer
187 views

Collection<CaseItem> of entity CsgoItem[] not initialized when fetching count

I have the following entity set up: @Entity() export class CsgoItem extends CommonBaseEntity { @Property() name: string; @Property({ nullable: true }) condition: string; @Property({ ...
Bowis's user avatar
  • 610
0 votes
0 answers
210 views

docker container exec mikro-orm migration wont exit after success

I have an ecs container that im running for my mikro-orm migrations. I need this container to exit after success for the task to stop running. I have tried numerous different approaches such as: "...
Dale's user avatar
  • 65
2 votes
1 answer
484 views

Why is Mikro-orm sending back numbers as strings?

I have a postCount property on a User entity that looks like this: @Property({columnType: 'bigint', nullable: false, default: 0}) postsCount: number; I expect it to come back as a number, but it ...
Connor Marble's user avatar
0 votes
1 answer
570 views

How to insert into a table the result of a select query with mikro-orm

I make a project with postgresql and I use mikro-orm to work with it. There is a table of the following structure: id | foreign_id | created_at ---+------------+----------- 1 | 2 | 2023-05-...
isqua's user avatar
  • 1,665
-1 votes
1 answer
471 views

Mikro ORM unique decorator is not being enforced when

Using this entity: @Entity() @Unique({ properties: ['case', 'csgoItem'] }) export class CaseItem { @PrimaryKey({ type: 'uuid', defaultRaw: 'uuid_generate_v4()' }) id: string; @Property({ type: '...
Bowis's user avatar
  • 610
0 votes
1 answer
286 views

MikroORM: No Update Event Fired When Adding an Entity to a Collection

In MikroORM, I have two entities, let's call them Entity A and Entity B, set up with a one-to-many relationship. Entity A has a Collection of Entity B instances. I'm using an event subscriber to ...
Voytech's user avatar
0 votes
0 answers
261 views

Mikro ORM Virtual entity not being present in service

I have the following NestJS route set up: @Get(':id') async getUserInfo(@Param('id') id: string) { const res = await this.userService.findOneByField(id); console.log(res); return res; ...
Bowis's user avatar
  • 610
0 votes
1 answer
531 views

Mikro-ORM w/MongoDB does not detect changes to arrays or insert new values

The problem I'm facing is that Mikro-ORM doesn't seem to detect array changes or be able to insert values into arrays. For example when inserting a number into a numbers array. I'm using MongoDB which ...
foal20ym's user avatar
0 votes
1 answer
371 views

Mikro ORM validation errors not catched

I have the following function: @SubscribeMessage('sendMessage') async handleSendMessage( _: Socket, payload: CreateMessageInput, ): Promise<void> { try { const created = ...
Bowis's user avatar
  • 610
1 vote
0 answers
301 views

Generic EntityById pipe nest js

I'm Trying to Implement a Generic EntityById Pipe Similar to the one From the Nest.js Documentation's Pipe Transformation UseCase UserByIdPipe, for that I can implement this simply like this @...
mohamed Arshad's user avatar
0 votes
1 answer
50 views

Why cant I install @mikro-orm/mariadb

Trying to install mikroorm into adminjs. I am using:https://mikro-orm.io/docs/usage-with-adminjs I ran the command npm install @mikro-orm/mariadb as instructed in the guide and it returns npm ERR! ...
The Rodeo Expert's user avatar
1 vote
0 answers
277 views

NestJs migration TypeError: Class extends value undefined is not a constructor or null

I'm trying to implement multitenancy in NestJs service (using mikro-orm), I have 2 abstract entities: BaseEntity which has id primary key only and MultiTenantEntity which extends BaseEntity and has ...
Arkadi's user avatar
  • 1,307
2 votes
1 answer
402 views

Is it possible to initialise ORM module with dynamic parameters in NestJs?

I'm using NX monorepo with NestJs apps (auth-service, other-service, etc.). I also created separated library for storing migrations libs/database.migrations and another library libs/database.mikro-orm ...
Arkadi's user avatar
  • 1,307

1
2 3 4 5