I’d like for mongo to generate it’s _ids as strings. They’re much more useable when sending back and fourth to the client or using in other parts of the program.
Right now I convert them to strings for all this stuff and then convert them back to run queries.
Any ideas or reasons not to?
You can set the _id however you want. You could even create an ObjectId, convert it to a string, and then save the string instead of the actual ObjectId. The main thing you would lose here is compactness. A minor thing you would lose is the ability to extract values out of the ObjectId without casting it, like the date, etc.
An example:
Update: You would have to recast it to an ObjectId to do this: