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.
3,776
questions
0
votes
1
answer
21
views
Entities won't join even if there is a relation between them when calling find or findOne functions
I'm trying to create an entity called author that have an array of already existing entities called books,The function returning value returns the desired value but when I try and see the created ...
0
votes
0
answers
9
views
What is the correct way to specify eager: true for a one-to-one relationship
What is the correct way to specify eager: true for a one-to-one relationship? Failed: order.entity.ts:
@OneToOne(() => HistoryStatusYd)
@JoinColumn( {eager: true} ) historyStatusYd: ...
0
votes
0
answers
13
views
TypeORM custom repository not overriding createQueryBuilder
I am trying to implement database i18n for TypeORM. I have been able to do that theoratically. But I also want to override built-in repository methods to use i18n (basically intercepting them and ...
0
votes
0
answers
15
views
Nest custom repository function not define
I have a small question about custom repositories in nestjs.
I have the following logic when a request comes in (for example for user entity).
A controller for the user requests -> service -> ...
0
votes
0
answers
35
views
NestJS - TypeORM - Unable to track the Entity Not Found in TypeOrm & Nest.JS
No repository for "UserEntity" was found. Looks like
this entity is not registered in current "default" connection? +114ms
RepositoryNotFoundError: No repository for "...
0
votes
1
answer
47
views
Get related data from another typeorm table (Adminjs integration)?
Is it possible in TypeORM, PostgreSQL, AdminJs with One to Many table relationships to immediately receive data from the associated table, and not a link to this data, as in my example.
@Entity()
...
0
votes
1
answer
41
views
TypeORM insert row with one to one relationship
I have three tables user, userCareerProfile, userPersonalProfile with @OneToOne relationship.
User Entity:
@Entity({ name: 'users' })
export class User extends AbstractEntity {
@Column({ unique: ...
0
votes
0
answers
9
views
Typescript Decorator and Babel: ColumnTypeUndefinedError: Column type for Exercise#name is not defined and cannot be guessed
Despite having babel-plugin-transform-typescript-metadata installed I have this error below:
ColumnTypeUndefinedError: Column type for Exercise#name is not defined and cannot be guessed.
Make sure ...
0
votes
0
answers
10
views
Error during Data Source initialization error: password authentication failed for user "root" when start with pm2
I'm deploying Nodejs application to Droplet of Digitalocean.When I start it normal(npm start), it work perfectly.But when i start with pm2 , i get this error in pm2 logs.
Error during Data Source ...
0
votes
0
answers
14
views
Graphql querying many to many relationship
I have two entities Events and Profiles which have a many to many relationship. Im attempting to query an event with its associated profiles like so.
{
event(id: 7){
id
username
...
0
votes
0
answers
19
views
@nestjs/typeorm How to get current connection with v0.3.0 of typeorm in a custom decorator?
I used to have:
import { getManager } from "typeorm";
return getManager()
.count(entity, {
...where,
})
.then((count) => count < 1);
to use the current connection in a ...
1
vote
0
answers
10
views
typeorm - understand provider scope and connection pooling
Does typeorm have a way to cache/store connection for a tenant/schema so that we can use the cached database connection per schema/tenant?
This document describes of a method to inject the connection ...
0
votes
0
answers
17
views
Class that has nested array properties in typeorm
I'm using TypeORM with Postgresql and having trouble creating entity file with nested scheme
The records I would like returned from my database should look like this:
[{
id: 1,
name: 'john'
...
0
votes
0
answers
12
views
getting a tenant specific repository in typeorm
I was looking for configuring multitenant support per request for users without having to reconfigure connections on the fly and not use a query builder, exactly as described in this post.
In one of ...
0
votes
0
answers
35
views
Subquery returns more than 1 row (1242)
I'm trying to update a table by his Primary Key, but MySQL(AWS RDS) is returning an error that says "Subquery returns more than 1 row". I'm already done the select with same "where"...
0
votes
0
answers
9
views
TypeORM does not respect UnionTypes in FindOneby function
I have created a Union Type which looks like this
type Nullable<T> = T | null;
This type is used in my application and has also worked without problems so far, e.g. such a type is passed to a ...
0
votes
0
answers
14
views
I can't update information from inside the entity with typeorm
I'm building a "forgot password" controller, so my goal in "forgotPasswordController" is to generate a token and send it to my user entity, but the problem is that even following ...
0
votes
0
answers
8
views
TypeORM automatic nested JSON when joining table in getRawMany
I got problem with TypeORM return here.
My query code :
const data = await MatchDetail.createQueryBuilder('md')
.select([
'team.*',
'sum(md.totalPoint) as teamTotalPoint',
])
.innerJoin('...
0
votes
0
answers
18
views
NestJS & TypeORM addEntitiesByConnection is not a function
I'm currently working on a project that has a backend that uses NestJS and TypeORM with a Postgres db, running in Docker. It used to work fine, but now it suddenly gives this error message whenever I ...
1
vote
2
answers
25
views
TypeORM Entity Validators not working when E2E testing GraphQL API with SuperTest
Morning everybody!
Tech Stack: NestJS + GraphQL + TypeORM
Have a strange problem with TypeORM Entity Field validators (@IsURL() & @IsNotEmpty()) not working when running E2E tests using SuperTest ...
0
votes
0
answers
12
views
How can I search of a word in a column in 2 diffrent repositories using one query (MySQL and TYPEORM and nestjs)
I'm using MySQL with Typeorm in nestjs the latest versions of them and I have these entities:
The shop.entity.ts:
@Entity()
export class Shop {
@PrimaryGeneratedColumn("uuid")
id: string;...
2
votes
3
answers
42
views
Argument of type '{ id: string; }' is not assignable to parameter of type 'FindOneOptions<Seller>'
Using mongodb by typeorm with nestjs - create crud rest api
when trying to get data by findone() with 'id' . getting below error
TS2345: Argument of type '{ id: string; }' is not assignable to ...
0
votes
0
answers
45
views
Linking tables not by field id primary key TypeORM PostgresQL nest.js
TypeORM PostgreSQL nest.js
You need to create a one-to-many relationship between the "request_id" field of the Orders table and the field of the same name in the Items table
One order, many ...
0
votes
0
answers
10
views
TypeORM sets @BeforeUpdate() and @BeforeInsert() dates as '0000-00-00 00:00:00' instead of current datetime in MySQL tables
I have tried several variations of this code in order to make it work. Regardless of what I set the column type (timestamp, datetime, date) or updatedAt data type (string or number)
@Column({
...
1
vote
0
answers
21
views
How to change "mpath" field name of materialized-path tree in typeorm?
I hope you are well.
Is there any way to change the name of the "mpath" column that is automatically generated when using the materialized-path tree structure on typeorm?
0
votes
0
answers
15
views
Can I use TypeOrm's FindOperators inside a base class without getting bad SQL Unknown column '_type' in 'where clause'
I am trying to write a base class for CRUD operations for "typeorm": "~0.2.45" under "@nestjs/typeorm": "~8.0.3" using node v14.19.3.
The base class looks like ...
0
votes
1
answer
28
views
Best way to share NestJS entities(or modules) between the private applications
We've been using the NestJS to build the backend service(=original project from now on). We're also going to create another NestJS application which is depending on same database with the original one ...
0
votes
0
answers
16
views
How should I send my token inside my user entity?
Well, I'm making a "forgot password" controller, in which the user sends the email and receives in his mailbox a token that expires in two hours so that he can use it to create a new ...
-2
votes
0
answers
28
views
Postgres: Almost concurrent updates to the same row executed later with empty field values
We have a Postgres database running in GCP (CloudSQL).
Whenever there are multiple UPDATE queries to the same row (followed by SELECT queries in between) within fraction of seconds, we're seeing a ...
0
votes
0
answers
13
views
TypeORM: Access property with select:false inside class method of entity
I am building an application in Typescript using TypeORM, Express and Passport for authentication.
I have defined a user model in TypeORM within the file entities/User.ts.
The password field is ...
0
votes
1
answer
20
views
TypeORM 0.3.6 errs processing raw SQL while running migrations
I am working with the below code, which worked fine with typeorm 0.2.x. I am trying to upgrade my packages to 0.3.6. It could be that the problem is somehow Mac-specific. Yet, I am not sure.
The ...
0
votes
1
answer
16
views
TypeORM looping on WhereExpressionBuilder result same value
I have a problem, I need to show all the rows containing certain tags.
on the database tags format like one,two,three
here my WhereExpressionBuilder code.
const tags = ['one','twoo','three']
...
0
votes
1
answer
23
views
How to use TypeOrm in a database already in production?
we have a platform already in production with a MySQL database, our goal is to create another platform consuming the same database...
Is it possible to use TypeOrm on a database already in production?
0
votes
0
answers
22
views
Force all queries to be executed on master for replication setup
My team wants to set up read/write replication, but has code like this all around:
// typeorm version: 0.2.41, DB: MySQL (AWS RDS)
function createUser(user): User {
await userRepository.save(user)
...
0
votes
0
answers
34
views
MySQL / Mariadb - Duplicate entry '1' for key *****
So I migrated a NodeJS backend from express to NestJS + TypeORM
But now I keep getting this error:
Duplicate entry '1' for key 'IDX_b37305d1c6376498a51b97ce1a
But where ever I look in the database, ...
0
votes
0
answers
28
views
Don't switch Adminjs to nestjs typeorm
Trying to connect Adminjs to nestjs typeorm.
Unable to start the application, writes an error:
UnhandledPromiseRejectionWarning: NoResourceAdapterError: There are no adapters supporting one of the ...
0
votes
0
answers
21
views
Save ManyToMany relation with typeorm and nestjs
I'm trying to save a subtype with ManyToMany relation but the record for the pivot table is not being saved I don´t know why :c
This is my entity MovementType:
@Entity({ schema: 'Catalogue' })
export ...
1
vote
0
answers
46
views
+100
typeorm - DEFAULT is being inserted while giving value to the specified entity
I'm using the migration workaround to seed my database in typeorm, and have got a foreign key, that I'm trying to link to the database, yet, it tells me that foreign key constrained is violated and ...
0
votes
0
answers
22
views
No repository for _ was found. Looks like this entity is not registered…
I need your help because this is really starting to get to me.
I can't seem to solve this error with TypeORM and NestJS.
ERROR [ExceptionHandler] No repository for "CommentRepository" was
...
0
votes
0
answers
17
views
Cascade multiple relations to one table [closed]
I have a ManyToOne and a OneToOne relation between to entities: a profile has photos attached, and one of them is selected.
It works fine until I try to cascade insert. These are the entities I use:
//...
2
votes
0
answers
21
views
TypeORM: problem of abstract entity relationship
Is that possible to have a entity relationship to a abstract entity class?
since all entity in my project might associated with one or more image(e.g. userEntity, categoryEntity), which I wonder is it ...
1
vote
1
answer
41
views
create a primary key for a one-to-one relationship
Background:
Since any unique entity data is a candidate key to a table, any data column constrained as unique is a candidate key. What is the syntax for a foreign key to be constrained as unique and a ...
0
votes
0
answers
17
views
Expected Iterable, but did not find one for field \"Photo.metadata\"." error in Apollo GraphQL
I have a server created with TypeORM and Apollo Server. I have Photo resolver which include relations. My server is working and getting data from PostgresSQL database. Here how I connected to my ...
2
votes
0
answers
36
views
SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string error typeORM
Error: SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string
I looked for some solutions for this one in the stack overflow and many say it would be a dotenv problem, but in my case the ...
0
votes
0
answers
26
views
TypeORM Error sending information to the database
When trying to make a request using postman, my console returns the error:
(node:25151) UnhandledPromiseRejectionWarning: ConnectionNotFoundError: Connection "default" was not found.
...
0
votes
0
answers
24
views
Typeorm - Create Postgres IDENTITY Column with EntitySchema
With Typeorm, I know that I can create a Postgres IDENTITY column like this:
class User {
@PrimaryGeneratedColumn('identity', { generatedIdentity: 'ALWAYS' })
id: number;
}
But how can I do ...
1
vote
1
answer
42
views
Select columns from sub-relation not working in typeorm
I have an Order and User Entities
Order
@Entity('orders')
export class Order {
@PrimaryGeneratedColumn()
id: number;
@Column('enum', {enum: OrderStatus, default: OrderStatus.NEW})
...
0
votes
0
answers
18
views
Timezone in nodejs, typeorm and postgresql
I have a problem with the time of my database records. The database time zone is ok, in the region I need. Not in the api, I always have to put the process.env.tz in the region I need. Even so, I can'...
0
votes
1
answer
27
views
I am trying to clear typeorm mysql database on server shutdown (NestJS)
How do I delete all entries in my database on server shutdown?
export class RoomsService {
async onApplicationShutdown() {
await this.roomService.deleteAll()
}
async deleteAll(): Promise<...
3
votes
1
answer
38
views
Typescript Add types to libraries method arguments
I am using an external library pg-mem which exposes LibAdapters and it has a method createTypeormConnection which accepts few arguments but of type any.
export interface LibAdapters {
...