Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
120 views
in Technique[技术] by (71.8m points)

node.js - database.js: colName.split is not a function

I'm getting an error when I try connecting to my DB from my index.js document (think app.js).

/var/www/HTML/node_modules/mongojs/lib/database.js:65
    var parts = colName.split('.')
                        ^

TypeError: colName.split is not a function
    at /var/www/HTML/node_modules/mongojs/lib/database.js:65:25
    at Array.forEach (<anonymous>)
    at new Database (/var/www/HTML/node_modules/mongojs/lib/database.js:62:8)
    at module.exports (/var/www/HTML/node_modules/mongojs/index.js:5:12)
    at Object.<anonymous> (/var/www/HTML/index.js:22:12)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)

I can't find anything on this error by Googling, and I don't know where colName is defined, I can't seem to find it.

database.js is obviously a part of the default mongoJS module, but if its broken after a clean install id think someone would've noticed before me, so I'm guessing I've made a mistake somewhere?

Connecting to my DB:

const connectionString = "admin:[email protected]/dbName:27017"; 
const collections = ["users", "inventories"];
const mongojs = require("mongojs");
const db = mongojs(connectionString, [collections])

Then I'm using this to query my DB:

db.users.find({steamid: userSteamId}, function(err, users){
      if(err || !users){
        console.log("No account found, prompt for tradelink to create acct");
      } else users.forEach( function(tradelink){
          console.log(tradelink);
        });
    });

I'm using MongoJS, NodeJS, and Express, on a Ubuntu server, let me know if any more detail is needed.

question from:https://stackoverflow.com/questions/65643309/database-js-colname-split-is-not-a-function

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...