Monday, 17 April 2017

Loop through a image file

So I have a large file of 68 images that I need to display one after another in a gallery type format, but I do not want to type them all out for obvious reasons of time and performance. What I need to do is loop through my file grabbing out all of the images and save them to mongoDB. Is there a way to do this? Also if this is possible would this code work for pulling them out of the database and sending them to my EJS file where I would print them out?

app.get("/gallery", function(req, res){
    Gallery.find({}, function(err, photos){
        if(err){
            console.log(err);
        } else{
            res.render("gallery", {photo: photos});
        }
    });
});

I'm new to Node and mongoDB so any help is welcome!



via Alex Richardson

No comments:

Post a Comment