Passing undefined to findOne({_id: undefined}) returns the first item in db
See original GitHub issueAs mentioned in the title
const user1 = await users.findOne({ _id: undefined });
will return the first item in the db
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
 Top Results From Across the Web
Top Results From Across the Web
.findOne(undefined) returns first item in the database instead ...
I completely disagree. Passing undefined shouldn't cause passing null to sql query. Null and undefined are completely different primitive values ...
Read more >mongoDB collection.findOne() returns undefined
log() in the function works, but when using it from another file it returns undefined. const db = client.db('TestDatabase'); const collection = ...
Read more >Mongoose v6.8.1: Model
The id is cast based on the Schema before sending the command. This function triggers the following middleware. findOne(). * Except for how...
Read more >typeorm/typeorm - Gitter
If entity already exist in the database, then it loads it. but if no existing entity is found in the database it returns...
Read more >Collections | Meteor API Docs
Finds the first document that matches the selector, as ordered by sort and skip options. Returns undefined if no matching document is found....
Read more > Top Related Medium Post
Top Related Medium Post
No results found
 Top Related StackOverflow Question
Top Related StackOverflow Question
No results found
 Troubleshoot Live Code
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free Top Related Reddit Thread
Top Related Reddit Thread
No results found
 Top Related Hackernoon Post
Top Related Hackernoon Post
No results found
 Top Related Tweet
Top Related Tweet
No results found
 Top Related Dev.to Post
Top Related Dev.to Post
No results found
 Top Related Hashnode Post
Top Related Hashnode Post
No results found

We can close the ticket, I did not know the undefined field is ignored. So essentially passing
findOne({ _id: undefined })is the same asfindOne().Thank you for your time.
@Kylescottw Has your problem been resolved?