-
Type: New Feature
-
Resolution: Unresolved
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: BSON
How are you using Mongo? What version of the server and driver are you using?
I am using the BSON library in an environment that imports from commonjs and es module versions of the BSON package. Or I'm using the BSON library in an environment with cross realm boundaries such that instanceof is unreliable.
What is the feature/improvement you would like?
I would like a static method much like Array.isArray for each BSONValue class that returns a boolean for whether or not the input is an instance of the corresponding BSON class.
// ex. ObjectId.isObjectId(oid) // true Int32.isInt32(oid) // false
What use case would this feature/improvement enable?
It would provide a public API way to identify a bson type at runtime, the current method is to use the semi-private _bsontype property.
- related to
-
MONGOSH-1421 [ESM] signatures of bson v5 are different from v4
- Closed
-
NODE-4858 Decouple BSON type interpretation from BSON type structure
- Backlog
-
NODE-5146 Establish support for ObjectId as the filter argument to find APIs [non-breaking]
- Backlog