Tuesday 9 May 2017

How to echo out information from mongodb with node js

in PHP it's very easy to echo out information from a MySql-database and encapsulate the result with html-attributes with a query like:

$query = "SELECT * FROM files ORDER BY ID DESC";
        $response = mysql_query($query);
        while($row = mysql_fetch_array($response)) {    
              echo '<img src="'.$row["image"].'" alt="..." />';

How would i go about doing something similar in node js from a MongoDB server? My collection looks like this:

"_id" : ObjectId("59106cc31bcace320c33a9d3"),
"path" : "uploads/bicycle.jpg",
"originalname" : "bicycle.jpg",
"__v" : 0

Thanks in advance!



via Joel

No comments:

Post a Comment