You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.
When trying to pull these documents through mongodb-rest, I receive the following error:
node.js:178
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Object e5e781f9-2947-4198-adca-f4d452e98c1a has no method 'toHexString'
at Object.flavorize (/usr/local/lib/node/.npm/mongodb-rest/0.6.7/package/lib/util.js:22:25)
at /usr/local/lib/node/.npm/mongodb-rest/0.6.7/package/lib/rest.js:50:32
at Array.forEach (native)
at /usr/local/lib/node/.npm/mongodb-rest/0.6.7/package/lib/rest.js:49:18
at /usr/local/lib/node/.npm/mongodb/0.9.2/package/lib/mongodb/cursor.js:122:15
at /usr/local/lib/node/.npm/mongodb/0.9.2/package/lib/mongodb/cursor.js:167:11
at /usr/local/lib/node/.npm/mongodb/0.9.2/package/lib/mongodb/cursor.js:467:28
at [object Object].close (/usr/local/lib/node/.npm/mongodb/0.9.2/package/lib/mongodb/cursor.js:625:17)
at [object Object].nextObject (/usr/local/lib/node/.npm/mongodb/0.9.2/package/lib/mongodb/cursor.js:467:10)
at Array. (/usr/local/lib/node/.npm/mongodb/0.9.2/package/lib/mongodb/cursor.js:161:12)
On line 21 of the /lib/util.js package, a suggestion would be to put another 'if' statement to check if the _id is a Mongo ObjectID or just a string. Something like:
if (id == ObjectID) {
doc._id = doc._id.toHexString();
} else {
// leave doc._id alone
}
Just a suggestion, this could be a rare case since most people let Mongo (or the driver) create the ObjectID. This just happens where the project I'm on, I'm given a unique ID that is mapped to other data sources outside of Mongo via this UUID.
Great work, thanks.
Matt
The text was updated successfully, but these errors were encountered:
+1 to mgd216,
Here it is assumed that the _id would be always going to be of BSON type ObjectID, which is false assumption. The assumption is made at following links, and other places as well.
Guess, one should be able to dictate using config.js ( or mongodb-rest should be able to do a smart guess) as what is the BSON type for _id field. E.g when it comes to uuid as values for _id, the BSON Binary type with subtype as UUID should be used ( See http://bsonspec.org/#/specification )
@mgd216, any specific reason why you don't want to store UUIDs as BSON Binary type with subtype UUID ? Why you have choose BSON type string to store them, it will occupy twice the space that too with indexing overhead.
I have a program that is storing documents in MongoDB, but the program is creating it's own object ID (which is just a UUID). See example documents:
{ "_id" : "e5e781f9-2947-4198-adca-f4d452e98c1a", "isDone" : false, "description" : "New Task" }
{ "_id" : "07cea259-f333-4836-a53f-644d2428a382", "isDone" : false, "description" : "New Task" }
{ "_id" : "1dcf6de5-c634-44c4-b5d9-9e349612ed46", "isDone" : false, "description" : "New Task" }
{ "_id" : "dfd31230-4293-4539-aa55-292297474ec4", "isDone" : false, "description" : "New Task" }
When trying to pull these documents through mongodb-rest, I receive the following error:
node.js:178
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Object e5e781f9-2947-4198-adca-f4d452e98c1a has no method 'toHexString'
at Object.flavorize (/usr/local/lib/node/.npm/mongodb-rest/0.6.7/package/lib/util.js:22:25)
at /usr/local/lib/node/.npm/mongodb-rest/0.6.7/package/lib/rest.js:50:32
at Array.forEach (native)
at /usr/local/lib/node/.npm/mongodb-rest/0.6.7/package/lib/rest.js:49:18
at /usr/local/lib/node/.npm/mongodb/0.9.2/package/lib/mongodb/cursor.js:122:15
at /usr/local/lib/node/.npm/mongodb/0.9.2/package/lib/mongodb/cursor.js:167:11
at /usr/local/lib/node/.npm/mongodb/0.9.2/package/lib/mongodb/cursor.js:467:28
at [object Object].close (/usr/local/lib/node/.npm/mongodb/0.9.2/package/lib/mongodb/cursor.js:625:17)
at [object Object].nextObject (/usr/local/lib/node/.npm/mongodb/0.9.2/package/lib/mongodb/cursor.js:467:10)
at Array. (/usr/local/lib/node/.npm/mongodb/0.9.2/package/lib/mongodb/cursor.js:161:12)
On line 21 of the /lib/util.js package, a suggestion would be to put another 'if' statement to check if the _id is a Mongo ObjectID or just a string. Something like:
if (id == ObjectID) {
doc._id = doc._id.toHexString();
} else {
// leave doc._id alone
}
Just a suggestion, this could be a rare case since most people let Mongo (or the driver) create the ObjectID. This just happens where the project I'm on, I'm given a unique ID that is mapped to other data sources outside of Mongo via this UUID.
Great work, thanks.
Matt
The text was updated successfully, but these errors were encountered: