Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

195
Views
TypeOrm & MongoDB: Column aliases ignored on insert/save

When using column aliases with MongoDB, TypeORM does not use the alias (Column name) when inserting/updating records, it only uses it when querying data.

Expected Behavior

When declaring a class like this

@Entity({ name: 'users' })
export class User {
   @ObjectIdColumn() readonly id: ObjectID;
   @Column({ name: "first_name" }) firstName: string;
}

and inserting a new record with a MongoRepository like this

const newUser = this.usersRepository.create({ firstName: 'Joe' });
return await this.usersRepository.save(newUser);

I expect the fields in then record in the database to be snake case not camel case

Actual Behavior

firstName column is not mapped to first_name

Steps to Reproduce

Create an entity like the following and use the type orm MongoRepository to save a new record.

@Entity({ name: 'users' })
export class User {
   @ObjectIdColumn() readonly id: ObjectID;
   @Column({ name: "first_name" }) firstName: string;
}

Environment

Dependency Version
OS Windows 10
NodeJs 16.6.2
TypeORM 0.2.37
MongoDB 4.2

Crossposted from Github Issues

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!