@tgerk thanks for your comment. FindById(id) only finds ObjectId('yourId'). Already on GitHub? As a side note, for all of your res.json() calls with failures, you might want to consider http statuses other than 200, and it will help you troubleshoot later on if each one has a different message. The following operation returns a document in the bios collection where the contribs field contains the element OOP and returns all fields except the _id field, the first field in the name embedded document, and the birth field: copy. length < 1) {return next (new Error ('No docs found! Include the mongoose debug to on success case and failure care. See Mongoose - What does the exec function do? Thanks for your reply! We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products. You signed in with another tab or window. Stack Overflow for Teams is a private, secure spot for you and You can always update your selection by clicking Cookie Preferences at the bottom of the page. Successfully merging a pull request may close this issue. By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy. It is a little bit against the way you would expect working with promises, when a query returns nothing, but does not throw and error. they're used to gather information about the pages you visit and how many clicks you need to accomplish a task. Set internal options (like `_mongooseOptions` but public) on a query, feature(rejectIfNotFound) added query option. I'm not inclined to add this to the core unless there's a lot of demand for it. For more information, see our Privacy Statement. privacy statement. Have a question about this project? Sign in is it OK to use multiple blades of a feeler gauge to measure a larger gap, Filling between two list plots to reperesent a confidence band, How to find published article from arxiv preprint. We’ll occasionally send you account related emails. are you using express? The logs seem to indicate that 2 of your 3 POST requests to the /email route are coming back with null responses for doc. db.bios.findOne( { contribs: 'OOP' }, { _id: 0, 'name.first': 0, birth: 0 } ) It's a little clunky but it gets the job done. to your account. By clicking “Sign up for GitHub”, you agree to our terms of service and Learn more, We use analytics cookies to understand how you use our websites so we can make them better, e.g. You don't need to explicitly convert the id string here, you can pass the string to mongoose and it will cast the string to an ObjectId for you ( as long as the schemaPath for subscribersuserid is defined as an ObjectId ). if so, are you enabling debugging? Can the review of a tenure track application start before the reference letters arrive? We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products. By clicking “Sign up for GitHub”, you agree to our terms of service and Convert the string into ObjectId type before querying. If you make these changes and still see the time outs: @lineus Kev Changed code as per your suggestion. Thanks everyone. I have use findone() by the 'name' in my database, it return sth. I had the same problem. I will use this until the middleware issue is done. In order to solve the problem I had to add _id:String in to mongoose schema. Asking for help, clarification, or responding to other answers. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. Now Problem solved. Strangely enough Mongoose's debugging shows the following, correct query: users.findOne ( { _id: ObjectId ("5580c79aa11e7310b2985ab1") }) which queried directly on MongoDB finds the expected data: Learn more. We’ll occasionally send you account related emails. Such as mkdir -p, cp -r, and rm -rf. Milestone. We use essential cookies to perform essential website functions, e.g. rev 2020.11.4.37941, Stack Overflow works best with JavaScript enabled, Where developers & technologists share private knowledge with coworkers, Programming & related technical career opportunities, Recruit tech talent & build your employer brand, Reach developers & technologists worldwide. copied. I want to store UTC time for the date, so it will help to convert what timezone I required after.