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.

Argument of type 'ObjectId' is not assignable to parameter of type 'string | number | Date | ObjectID | FindOneOptions

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 [ ] cockroachdb [ ] sqlite [ ] sqljs [ ] react-native [ ] expo

TypeORM version:

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

Impossible to execute findOne(<ObjectID>)

import {ObjectID} from "mongodb";
....
async changeGalerie(id_photo:ObjectID, acces: number) {
    let photo = await this.candidatPhotoRepository.findOne(id_photo);
}

error TS2345: Argument of type ‘ObjectId’ is not assignable to parameter of type ‘string | number | Date | ObjectID | FindOneOptions<CandidatPhoto> | Partial<CandidatPhoto>’. Property ‘generate’ is missing in type ‘ObjectId’ but required in type ‘ObjectID’.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:12
  • Comments:21 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
moimstone-Crongcommented, Jul 21, 2021

same issue here. version 0.2.34

0reactions
sagun-kcommented, Nov 3, 2022

I am getting the same problem, ObjectID is deprecated by mongodb but query methods only accept one of kind of ObjectID

Read more comments on GitHub >

github_iconTop Results From Across the Web

Argument of type '{ id: string; }' is not assignable to parameter ...
Object literal may only specify known properties, and 'id' does not exist in type 'FindOneOptions'. Code: const result = await this.
Read more >
Type is not assignable to type 'OptionalId<T>' - MongoDB
I'm trying to write a Typescript generic using the Nodejs driver v4.1.0. ... Argument of type 'T' is not assignable to parameter of...
Read more >
Type 'undefined' is not assignable to type in TypeScript
The "Type 'undefined' is not assignable to type" error occurs when a possibly undefined value is assigned to something that expects a different...
Read more >
Class Repository<Entity> - typeorm
Deletes entities by a given criteria. Unlike save method executes a primitive operation without cascades, relations and other operations included.
Read more >
type-graphql/Lobby - Gitter
Argument of type '{ resolvers: (typeof PlaceResolver)[]; validate: boolean; emitSchemaFile: string; }' is not assignable to parameter of type ...
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