Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9246335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:27:53+00:00 2026-06-18T09:27:53+00:00

I am trying to set up a simple mongodb test server within my app.js

  • 0

I am trying to set up a simple mongodb test server within my app.js node application but I keep getting “TypeError: Cannot read property ‘arbiterOnly’ of undefined”. I am running it on local host and I have installed mongo db by running npm install mongodb in the folder I am making the application in. any help one what I am doing wrong would be greatly apreciated

here is my code for my application

var express = require('express')
  , routes = require('./routes')
  , user = require('./routes/user')
  , http = require('http')
  , path = require('path');
  var Db = require('mongodb').Db;
var Server = require('mongodb').Server;
var client = new Db('test', new Server('localhost:', 3100, {}));

var insertData = function(err, collection) {
    collection.insert({name: "Kristiono Setyadi"});
    collection.insert({name: "Meghan Gill"});
    collection.insert({name: "Spiderman"});
    // you can add as many object as you want into the database
}

var removeData = function(err, collection) {
    collection.remove({name: "Spiderman"});
}

var updateData = function(err, collection) {
    collection.update({name: "Kristiono Setyadi"}, {name: "Kristiono Setyadi", sex: "Male"});
}

var listAllData = function(err, collection) {
    collection.find().toArray(function(err, results) {
        console.log(results);
    });
}

var app = express();

app.configure(function(){
  app.set('port', process.env.PORT || 3000);
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.use(express.favicon());
  app.use(express.logger('dev'));
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(express.cookieParser('your secret here'));
  app.use(express.session());
  app.use(app.router);
  app.use(express.static(path.join(__dirname, 'public')));
});


client.open(function(err, pClient) {
    client.collection('test_insert', insertData);
  //  client.collection('test_insert', removeData);
    // etc.
});

var people = [{name:'Keth',age:'33',email:'ktater@gmail.com'},
{name:'Donny',age:'20',email:'donjuan86@hotmail.com'},
{name:'Loran',age:'26',email:'geegeenat@facebook.com'},
{name:'Max',age:'18',email:'axxanan@gmail.com'}];

app.configure('development', function(){
  app.use(express.errorHandler());
});

app.get('/', routes.index);
app.get('/users', user.list);
app.get('/people', function(req, res){
  res.render('peeps', {people:people});
});

app.get('/people/:id', function(req, res){
var guy;
  for (var i =0 ; i < people.length ; i++)
  {
    if(people[i].name == req.params.id)
      guy = people[i];

  }
  res.render('viewPerson', {guy:guy});
});

http.createServer(app).listen(app.get('port'), function(){
  console.log("Express server listening on port " + app.get('port'));
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:27:54+00:00Added an answer on June 18, 2026 at 9:27 am

    My first guess here is that the connection is not opening. Try logging err with console.log in the client.open function. Also, the post you’re getting your test code from is about 18 months old, it’s possible that the code is out of date.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to set up a simple UITableView with a UISearchDisplayDelegate but my app
I'm trying to set up a simple spring application and I'm getting the below
I am trying to set up a simple single-view iOS5 iPhone application (with AppDelegates,
I'm trying to set up a simple server side RSA encryption of a small
I am trying set up a simple dropdown list but I dont seem to
I'm trying to set up a simple window using C++, but my call to
I'm trying to set up a simple test to make a POST request to
I'm trying to set up a simple chat using node.js (no express) and socket.io.
I am trying to set up a simple hit counter within expression engine using
Trying to set up a simple .jsp to test JavaScript regular expressions and avoid

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.