I have data in MongoDB that I am trying to pass through to an ejs template through express and Mongoose - However when the data is rendered it behaves like it's undefined(I can't console.log the object I can't access it through any of my javascript files(I would like to access it in a separate javascript file that contains code that is centered around manipulating page elements not main app functionality) ) I am very new to programming I'm looking for a little guidance on how I would be able to take this mongoDB document and put it into a variable that I can manipulate with a javascript file. In order to reveal certain properties in the document as I see fit.
// app.js file that has express route to home page with mongoose model
var express = require("express"),
app = express(),
bodyParser = require("body-parser"),
mongoose = require("mongoose");
mongoose.connect("mongodb://IP:PORT/users", { useNewUrlParser: true });
app.use(express.static("public"));
app.use(express.static("routes"));
app.use(bodyParser.urlencoded({extended: true}));
app.set("view engine", "ejs");
var technologySchema = new mongoose.Schema({
Image: String,
Name: String,
desc: String
});
var Technology = mongoose.model("Technology", technologySchema);
app.get("/", function(req, res){
console.log(techList);
Technology.find({}, function(err, alltechrecords){
if(err){
console.log(err);
}else{
res.render("home", {technologies: alltechrecords});
}
});