Provide utility function to allow easier reading and usage of ObjectIds
Provide a utility that allows easier parsing of ObjectIds when they're returned to the client. As it stands, ObjectIds are returned as UInt8Arrays and cannot be readily used in the BSON.ObjectId constructor. Being able to retrieve specific items by ObjectId is necessary and the only way to do this dynamically (without knowing the hex string beforehand) is to retrieve the items and then use the returned id; however, as it stands, using the returned id is obfuscated and impractical.
I am now having to use the following workaround:
const toHexString = (bytes) =>
bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, "0"), "");
client.find({_id: new BSON.ObjectId(toHexString(arr: Uint8Array)})