Skip to content

Mongo - properties that aren't defined are saved to database #5321

@flobiber

Description

@flobiber

Issue type:

[x] question
[ ] bug report
[ ] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[x] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[ ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo

TypeORM version:

[x] latest
[ ] @next
[ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

@Entity()
export class User {
  @ObjectIdColumn()
  id: number;

  @Column()
  firstName?: string;
}

repo.save({
  firstName: 'My',
  lastName: 'Me' //<- This is possible, although it's not defined! 
})

Is there a possibility to forbid saving not described properties?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions