louischatriot / mongo-edit

A simple REST gui for MongoDB
228 stars 32 forks source link

Edit/Save Doesn't work for custom _id's (due to ObjectID() restrictions) #13

Closed Pugio closed 11 years ago

Pugio commented 11 years ago

docEdit.js and docChange.js both query on: { _id: new ObjectID(req.params.id) } , but this only works when the id is actually an ObjectID (ie. a 12-byte string). For custom IDs, this creates an error:

Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters

Changing the queries to use: { _id: req.params.id } seems to work fine.

louischatriot commented 11 years ago

Hello,

I used this construct because that's the way I do it in the Mongo shell. I didn't try the simple form you suggest and if it works I see no reason not to do it so I'll take a look at it.

Thanks for the heads up!

louischatriot commented 11 years ago

Just took a look at it, and it doesn't work with a simple { _id: req.params._id }. Could you make a PR so that I can test a full working PR that works on your system ? I'm closing this issue meanwhile. Thanks !