While trying other people solutions for this doesn't seem to fix this error for me. What I am trying to do is for each I in the array
which my array comes from below
novel.ts
export let indexList = (req: Request, res: Response) => {
novel.getAllDocuments((data) => {
const novelObj = Convert.toNovelObj(data);
res.render(`novels/all`, {
title: `List of novels`,
array: {
name: novelObj.novelName,
author: novelObj.novelAuthor,
id: novelObj._id,
img: novelObj.novelCoverArt,
tags: novelObj.novelTags
}
});
});
};
the novelObj
converts my MongoDB from json to objects which can be seen below
RiNovel.ts
public getAllDocuments(callback: (data) => void) {
var chapterInfoModel = mongoose.model('Novels', RiNovelcheme);
chapterInfoModel.collection
.find()
.stream()
.on('data', function(doc) {
const novelObj = Convert.novelObjToJson(doc);
return callback(novelObj);
})
.on('error', function(err) {
})
.on('end', function() {
});
}
all.pug
each i in array
p= i.name
the error is when there are multiple documents inside of my collection, how would I fix this