Hi @Kevin_Turney, it is difficult to tell where the issue is with what I am seeing. But, can you verify the OrdersDAO class and see where all the field orders is used? By chance, is it redefined (or reassigned somewhere)?
Hi @Kevin_Turney, it is difficult to tell why your code is not working with what is posted. It is a possible that there are different versions of the code and there is some conflict somewhere.
This is unrelated, but you don’t have a return statement in the getOrders method, but, the controller code is showing that you are expecting a return value. Also, there is a return in the injectDB (what is it for?). Are you sure you had posted the same code you are running (please verify again)?
Thanks Prasad, you put a heroic effort in trying to help me. I was experimenting with the return in injectDB, it had no effect. As for the the getOrders(), if I could console.log, then I know I could eventually return what the controller expected. I really wanted to work with node driver, I did not want to use Mongoose, but I may have to if I can’t get this to work by tomorrow.
@Kevin_Turney, you don’t necessarily need to use Mongoose. Instead try the following method:
To establish a reusable connection (So that we can access the connected database from any other file), I created an async function in my db.js file where the connection is established and then exported it. In the end of the file, I have called the function. The code is as follows:
const productCollection = require('./db').collection("product");
This code gives me no error and works perfectly fine. With the help of the above code, one can use this conveniently while following the MVC (Model-View-Controller) framework.