Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot read property 'ObjectID' of undefined

I am forking / try to understand mongodb-rest project. When I am running only the rest.js script I get this error:

TypeError: Cannot read property 'ObjectID' of undefined
    at app.post.connection.connect.res.status.json.message (/var/lib/openshift/5556b4c4fcf9336abf0000de/app-root/runtime/repo/server.js:99:32)

at this line, when I try to handle PUT message:

var spec = {'_id': new BSON.ObjectID(req.params.id)};

I have the same 'include' lines as rest.js

  var mongodb = require("mongodb");
  var BSON = mongodb.BSONPure;

but running on OpenShift servers.

Any idea what is wrong?

UPDATE

I tried to use same package:

  var bson = require("bson");
  var BSON = bson.BSONPure.BSON;
  //var BSON = mongodb.BSONPure;

got same error

like image 869
János Avatar asked Mar 16 '23 23:03

János


1 Answers

Try using the bson package instead of mongodb:

var BSON = require('bson').BSONPure
like image 154
chridam Avatar answered Mar 24 '23 07:03

chridam