question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'createValueMap' of undefined

See original GitHub issue

Issue type:

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

Database system/driver:

[ ] cordova [X] mongodb [ ] mssql [ ] mysql / mariadb [ ] oracle [ ] postgres [ ] sqlite [ ] sqljs [ ] websql

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 {

    @PrimaryGeneratedColumn()
    id: ObjectID;

    @Column()
    name: string;
}

If using PrimaryGeneratedColumn instead of ObjectIdColumn, I get an error :

Error:  TypeError: Cannot read property 'createValueMap' of undefined
    at MongoQueryRunner.<anonymous> (C:\Users\atro\Work\typeorm-typescript-mongo-example\node_modules\typeorm\driver\mongodb\MongoQueryRunner.js:573:98)
    at step (C:\Users\atro\Work\typeorm-typescript-mongo-example\node_modules\typeorm\driver\mongodb\MongoQueryRunner.js:32:23)
    at Object.next (C:\Users\atro\Work\typeorm-typescript-mongo-example\node_modules\typeorm\driver\mongodb\MongoQueryRunner.js:13:53)
    at fulfilled (C:\Users\atro\Work\typeorm-typescript-mongo-example\node_modules\typeorm\driver\mongodb\MongoQueryRunner.js:4:58)
    at process._tickCallback (internal/process/next_tick.js:109:7)

The data is stored normally in the database. I just use the generated example:

// insert new users for test
    await connection.manager.save(connection.manager.create(User, {
        name: "Timber",
        email: "Saw",
        password: "test"
    }));

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:9
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

29reactions
wilfredlopezcommented, Apr 12, 2021

using @ObjectIdColumn instead of PrimaryGeneratedColumn works for me.

`ts import { Entity, PrimaryGeneratedColumn, Column, ObjectID, ObjectIdColumn } from “typeorm”

@Entity() export class User {

@ObjectIdColumn()
id: ObjectID

@Column()
firstName: string

@Column()
lastName: string

@Column()
age: number

}`

1reaction
Duskfallcommented, Feb 13, 2018

Thanks for taking the time to look into this! You missed the point where I changed the id to match the RDBMS database type ( or this is my thought at least ). If you change the User id which resides in src\entity\User.ts to use PrimaryGeneratedColumn decorator instead, we get this problem image

Read more comments on GitHub >

github_iconTop Results From Across the Web

NestJS TypeORM for MongoDB Crashing After Insert
repo.save(newEntity); , the data is saved to MongoDB. But, I also get the error cannot read property “createValueMap()” of undefined ...
Read more >
Cannot read property 'createValueMap' of undefined
TypeError : Cannot read property 'createValueMap' of undefined: 3c83fe6e-17d8-489d-8300-45aba1053f2b at MongoDriver.
Read more >
Cannot read property 'createValueMap' of undefined
Cannot read property 'createValueMap' of undefined. weixin_45440200 于 2021-02-02 23:14:54 发布 378 收藏. 文章标签: typescript nestjs node mongodb.
Read more >
typeorm/typeorm - Gitter
TypeError : Cannot read property 'name' of undefined. at Function.ColumnTypes.typeToString (eval at <anonymous> (server.js:1242:2), <anonymous>:70:20).
Read more >
Cannot read property 'createValueMap' of undefined
Cannot read property 'createValueMap' of undefined. typescript nestjs node mongodb. 记录一下,一个大坑,用 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found