Replace ObjectID method for node-mongo-native
The objectID object used in mongo seems to be a little difficult to deal
with when it comes to passing it back and forth with json and
communicating with other applications. It seems that to use it, I have to
convert back and forth between the object for querying and the string for
json message passing.
I think it would be great instead for node-mongo-native to create my _id's
as strings by default. Something like this would make a good unique id
generation system that also doubles as a timestamper:
function createID(){
return (Date.now() + ((Math.round(Math.random()*1000000))/1000000)
).toString();
}
Is there a way for me to have node-mongo-native use this function for id
generation instead of the default?
No comments:
Post a Comment