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

Incompatible formats of ObjectId (bson vs mongoose), after insertMany (rawResult: true) #11197

Closed
DmytroKurapin opened this issue Jan 8, 2022 · 2 comments
Labels
typescript Types or Types-test related issue / Pull Request
Milestone

Comments

@DmytroKurapin
Copy link

DmytroKurapin commented Jan 8, 2022

Do you want to request a feature or report a bug?
A bug

What is the current behavior?
I am using Nestjs with mongoose (latest version 6.1 5) and I have a compiler error, when I try to use insertMany with rawResult :true.

const rawData = await this.ideaModel.insertMany(docs, { rawResult: true });
 const ids: Types.ObjectId[] 
= [...Object.values(rawData.insertedIds))] 

And here is the Typescript error I get in this case:

Property ‘_id’ is missing in type ‘import(“/Users/###/node_modules/bson/bson”).ObjectID’ but required in type ‘import(“mongoose”).Types.ObjectId’. 

Nestjs/mongoose: 9.0.2
Mongoose 6.1.5
Typescript: 4.5.4

@vkarpov15
Copy link
Collaborator

Can you please provide a GitHub repo or gist that demonstrates this issue?

@vkarpov15 vkarpov15 added the needs clarification This issue doesn't have enough information to be actionable. Close after 14 days of inactivity label Jan 9, 2022
@DmytroKurapin
Copy link
Author

@vkarpov15 here is test repo for this issue:
https://github.com/DmytroKurapin/test-object-id

@vkarpov15 vkarpov15 added this to the 6.1.9 milestone Jan 15, 2022
@vkarpov15 vkarpov15 added has repro script There is a repro script, the Mongoose devs need to confirm that it reproduces the issue and removed needs clarification This issue doesn't have enough information to be actionable. Close after 14 days of inactivity labels Jan 15, 2022
@IslandRhythms IslandRhythms added typescript Types or Types-test related issue / Pull Request and removed has repro script There is a repro script, the Mongoose devs need to confirm that it reproduces the issue labels Jan 18, 2022
@vkarpov15 vkarpov15 modified the milestones: 6.2.2, 6.2.3 Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Types or Types-test related issue / Pull Request
Projects
None yet
Development

No branches or pull requests

3 participants