Take the 2-minute tour ×

I would like to create forum script with Node.js and MongoDB, but I have a problem with IDs which are pretty long in Mongo's case. I was already searching for solution, but I didn't find anything except the posts in which is written that I need to create ID's myself. I know more about PHP and MySQL, but I need Node for some realtime application in addition of forum. I would use generated ID for identifyng forum post, and next to it it would be thread's title - like this: address.domain/1/my-new-thread.

What do you recommend me?

share|improve this question
Why exactly are the default ID's not good? –  Chiel92 Mar 2 '13 at 14:19
If I put them into address, the URL would be too long - address.domain/re2525435tr5435/my-new-thread-with-long-long-long-title –  user1257255 Mar 2 '13 at 14:21
Take a look at this basic technique: docs.mongodb.org/manual/tutorial/… You could use it to generate the ID which you use directly, or build a map of "short id" to an ObjectId. –  WiredPrairie Mar 2 '13 at 15:07
just generate your own id besides the mongodbid and use that as lookup for your posts/threads whatever, you can't shorten the mongodb generated id because its a BSONID and there is no shorter form. –  supernova Mar 2 '13 at 20:17
add comment

1 Answer

up vote 1 down vote accepted

I've used mongoose-pureautoinc and it works without problems.

share|improve this answer
If you insist on answering your own question and accepting the answer so quickly, you could at least provide some source code on how you solved the issue. –  adrianp May 3 '13 at 12:44
@adrianp: the question is from March 2nd. What do you mean with "so quickly"? –  6502 May 3 '13 at 12:53
@6502 Sorry, misread the date; still, can you provide some code example? –  adrianp May 3 '13 at 12:54
add comment

Your Answer


