• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Node.JS Bizarre Node.js error

DennisM

New Coder
I'm trying to do some basic stuff with MongoJS. When I try to run this simple program:

JavaScript:
var database = "testingMongoJS";
var collection = "testCollection";

var db = mongojs(database, collection);

db.on("error", function(error){
    console.log("Database: ", error);

})

app.get("/", function(req, res){
    db.testCollection.find({}, function(error, found){
        console.log(found);

    })
})

I get this error:

Code:
C:\Users\Dennis\Desktop\UTAUS201801FSF2-FT-Class-Repository-FSF-FT\class-content\18-mongo-mongoose\01-Activities\11-Scraping-into-a-db\Solved\node_modules\mongojs\lib\database.js:57
  cols.forEach(function (colName) {
       ^

TypeError: cols.forEach is not a function
    at new Database (C:\Users\Dennis\Desktop\UTAUS201801FSF2-FT-Class-Repository-FSF-FT\class-content\18-mongo-mongoose\01-Activities\11-Scraping-into-a-db\Solved\node_modules\mongojs\lib\database.js:57:8)
    at module.exports (C:\Users\Dennis\Desktop\UTAUS201801FSF2-FT-Class-Repository-FSF-FT\class-content\18-mongo-mongoose\01-Activities\11-Scraping-into-a-db\Solved\node_modules\mongojs\index.js:5:12)
    at Object.<anonymous> (C:\Users\Dennis\Desktop\UTAUS201801FSF2-FT-Class-Repository-FSF-FT\class-content\18-mongo-mongoose\01-Activities\11-Scraping-into-a-db\Solved\myserver.js:12:10)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Module._load (node:internal/modules/cjs/loader:827:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47

What's the deal?
 
Top Bottom