findById returns no results even with correct ObjectId
Problem
Configuration: Mongoose 4.0.5, MongoDb 3.0.4, Node 0.12.4 Issue does not appear on Mongoose 3.8.30 My database has the following data: [code block] I query it with Mongoose using the following syntax: [code block] which returns null for both error and user. Strangely enough Mongoose's debugging shows the following, correct query: [code block] which queried directly on MongoDB finds the expected data: [code block] I tried various alternatives such as directly initializing an ObjectId object or taking an ObjectId from a `find()` result which leads to no results either. As stated above reverting back to Mongoose 3.8 resolves the issue.
Error Output
error and user**. Strangely enough Mongoose's debugging shows the following, correct query:
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: findById returns no results even with correct ObjectId
Aw sorry, copy-paste error from a test I ran at the command line. Should be this: [code block]
Trust Score
4 verifications
- 1
Aw sorry, copy-paste error from a test I ran at the command line. Should be thi
Aw sorry, copy-paste error from a test I ran at the command line. Should be this:
Validation
Resolved in Automattic/mongoose GitHub issue #3079. Community reactions: 5 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep