220
questions
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 ...
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({ ...
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.
...
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 ...
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-...
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: ...
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, ...
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 ...
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 ...
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 ...
-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 ...
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 ...
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[]'.
...
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 "./...
-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 '@...
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 ...
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(...
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 } ...
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 ...
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 ...
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....
-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 ...
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/...
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 ...
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 ...
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 ...
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 ...
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, ...
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({
...
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 ...
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 ...
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 [...
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 ...
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(...
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.
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 ...
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')
...
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({ ...
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:
"...
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 ...
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-...
-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: '...
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 ...
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;
...
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 ...
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 = ...
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
@...
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! ...
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 ...
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 ...