Search code examples
node.jsmongodbexpressmongoosenunjucks

nunjucks not outputting all data from MongoDB


I am using node.js as a scripting language and I am also using nunjucks as the template engine. I have a weird situation going where some of the data that I retrieve from the MongoDB database is not being printed into document.

As you see hear these are the values that I want to print to the web page enter image description here

But when you look at the web page, only some of the data has been printed out and the other information is missing. enter image description here

I console.logged the data to prove that the values are in the database enter image description here

A weird thing is that if you write the whole object into the code, like so enter image description here

It will output all the data in one block. That includes the month, the year, and slug property that I am trying to output to the page. Yet, it only does that if I print out the whole object enter image description here


Solution

  • I found out what was the problem. In my mongoose schema, I did not have the properties listed like slug, month, or date. So when I tried to retrieve data from those properties it did not output them. So If you are having similar problems make sure the properties are declared in your mongoose schema