ltonetwork / mongodb-rest

JSON REST server for MongoDB (using node.js)
MIT License
405 stars 143 forks source link

Crash on ObjectID.createFromHexString call #2

Closed subpop closed 14 years ago

subpop commented 14 years ago

When sending a PUT and trying to update an existing document, NodeJS crashes with:

mongodb-rest/lib/mongodb_rest.js:209
var spec = {'_id': mongo.ObjectID.createFromHexString(parameters['id'])};
                               ^
TypeError: Cannot call method 'createFromHexString' of undefined
at [object Object].updateDocument (mongodb-rest/lib/mongodb_rest.js:209:36)

My request is:

PUT /db/coll/4c6eb1c31d2df02815fb57f1 HTTP/1.1

{ "attribute": "hello" }
subpop commented 14 years ago

Actually, it crashes on any request that seems to call mongo.ObjectID.createFromHexString(). Even simple GET requests to /db/coll/idString

subpop commented 14 years ago

Poking around with this more, even in the node shell, I can't create ObjectID objects and call that method. This seems more like an issue with node-mongodb-native.

tdegrunt commented 14 years ago

Indeed I'm using the node-mongodb-native library. It seems that ObjectID is no longer exposed, but looking in the examples (type.js) from node-mongo-native it should be exposed. Looking into it as well...

tdegrunt commented 14 years ago

Could very well be that mongo 1.6.1 isn't supported by the native driver. I had tested all of this with 1.4.2, which worked fine. Not giving up though!

tdegrunt commented 14 years ago

Seems node-mongodb-native changed something I didn't expect. All calls to createFromHexString are removed, should look a lot better now.

subpop commented 14 years ago

Awesome. Works now. Good idea to have node-mongo-native as a submodule too. Now I don't have to keep both repositories separately.

tdegrunt commented 14 years ago

Thanks for your patience and submitting the issue(s).