{SOLVED : Mongoose - Cannot get data from collection "accoutings"} | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

{SOLVED : Mongoose - Cannot get data from collection "accoutings"}

Problem with MongoDB / Mongoose can get data in admin with /admin and data in overseas with /overseas but can't get data in accounting with /accounting My app.js : https://code.sololearn.com/WVe18BrqW0Bq/?ref=app

12th Feb 2020, 2:21 AM
Gordon
Gordon - avatar
2 Answers
+ 8
If the routes for admin and overseas are working properly it's safe to assume that the DB and connection are working as expected. Especially since you use the same abstract route for all defined todos. I would first start by checking to make sure there isn't a capitalization or spelling error (ie "Accounting" vs "accounting"). Secondly, you're using the query {done : true} in your DB.collections.find() method. If there are no accounting todos that are done already, none would return from the query. Try leaving the query blank by entering {} as the first argument to return all accounting todos with one query. I hope this helps. Everything looks fine otherwise.
12th Feb 2020, 2:53 AM
Mike Perkowski
Mike Perkowski - avatar
+ 2
Oh yes, I added that query for testing yesterday, my bad 😅 Yes now the todo of accouting are loaded as I expect, after removing that query object. (Here I don't have the first argument now, and let the callback be the first argument, and it still works 🤔) Thanks Mike for solving.
12th Feb 2020, 3:35 AM
Gordon
Gordon - avatar