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
I'd like to significantly shorten the _ids I pass to clients from my server, but I'm relying on the default toString() implementation in a ton of places. It would be way more convenient for me to be able to change the default encoding so that when I JSON.stringify my documents, ObjectIds automatically output as base 64. Is there a way to do this?
The text was updated successfully, but these errors were encountered:
Actually, to anyone who sees this issue, I would instead recommend doing new Buffer(doc._id.toHexString(),'hex').toString('base64') because the result ends up being smaller for some reason. I'm not entirely sure why, but it seems like objectId.id contains more information that needed to represent the id. At least that's what I found in my testing.
I'd like to significantly shorten the _ids I pass to clients from my server, but I'm relying on the default
toString()
implementation in a ton of places. It would be way more convenient for me to be able to change the default encoding so that when IJSON.stringify
my documents, ObjectIds automatically output as base 64. Is there a way to do this?The text was updated successfully, but these errors were encountered: