Answer the question
In order to leave comments, you need to log in
How to output MongoDB records to a page?
I have a books collection in MongoDB with fields like this:
title: title,
description: description,
author: author,
bookSource: bookSource,
imageSource: imageSource
var all_books = Book.find();
// и сгенерирую, передав результат
res.render("booksPage", { all_books: all_books });
<div class="booksBox">
<% for (var i = 0; i < all_books.length; i++) { %>
<div class="book">
<p class="title"> <%= all_books[i]["title"] %> </p>
<p class="description"> <%= all_books[i]["description"] %> </p>
<p class="author"> <%= all_books[i]["author"] %> </p>
<!-- И так далее... -->
</div>
<% } //конец for %>
</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question