Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mongodb: .save() method does not set _id column value #3517

Closed
encobrain opened this issue Jan 25, 2019 · 3 comments
Closed

mongodb: .save() method does not set _id column value #3517

encobrain opened this issue Jan 25, 2019 · 3 comments

Comments

@encobrain
Copy link

encobrain commented Jan 25, 2019

Issue type:

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

Database system/driver:

[ ] cordova
[x] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[ ] postgres
[ ] 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()
class EntityClass {
    @ObjectIdColumn()
    _id: ObjectId;

    @Column()
    name: string;
}

let ent = new EntityClass();
ent.name = "abc";

await connection.mongoManager.save(ent);

console.log(ent._id); // inserts new document but does not set _id. _id is undefined
@encobrain encobrain changed the title mongodb: .save() method not set _id column value mongodb: .save() method does not set _id column value Jan 25, 2019
@pleerock
Copy link
Member

@rustamwin

@rustamwin
Copy link
Contributor

I guess this problem related to 8f25eec
probably we need check objectIdColumn name?

@vlapo
Copy link
Contributor

vlapo commented Jan 27, 2019

Sry guys. I did not realize possibility of property name _id. Fix is coming in next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants