Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

query from database query in mongodb

let userBuilds = [];

    Wishlist.find({}, function (err, builds) {
        if (err)
        {
            console.log("Cannot fetch wishlisted builds");
            return res.redirect('back');
        }

        async.forEachOf(builds, function (build, key, callback) {
            Builds.find({ name: build.name }, function (err, detailBuild) {
                if (err)
                {
                    console.log("Cannot fetch detail from wishlisted builds");
                    return res.redirect('back');
                }

                userBuilds.push(detailBuild[0]);
                callback();
            });
        }, function (err) {
            if (err)
            {
                console.log("Error in rendering page");
                return res.redirect('back');
            }

            return res.render('wishlist', {
                title: "Wishlist",
                email: req.session.email ? req.session.email : undefined,
                builds: userBuilds,
                layout: false
            });
        });
    });
Source by www.codegrepper.com #
 
PREVIOUS NEXT
Tagged: #query #database #query #mongodb
ADD COMMENT
Topic
Name
1+5 =