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)})
![](https://secure.gravatar.com/avatar/85897c4d31b388729a947b6912a79b00?size=40&default=https%3A%2F%2Fassets.uvcdn.com%2Fpkg%2Fadmin%2Ficons%2Fuser_70-6bcf9e08938533adb9bac95c3e487cb2a6d4a32f890ca6fdc82e3072e0ea0368.png)