-
-
Notifications
You must be signed in to change notification settings - Fork 611
Description
Is your feature request related to a problem? Please describe.
Currently MikroORM works fine with Node.js Buffer. They are handled correctly in the EntityDTO type returned by the toObject method. Also BlobType can store them as expected in the database.
So far so good. But unfortunetely in browser applications we can only work with typed arrays. I'm working with a binary format (CBOR) in my API and data is transferred as Uint8Array since that is supported in both Node.js and browsers.
Describe the solution you'd like
I propose to support at least Uint8Array in BlobType and EntityDTO. Since Node.js Buffer basically is a Uint8Array and it usually is the drop-in replacement when browsers are involved.
Describe alternatives you've considered
Right now two extra conversion steps (incoming and outgoing) are necessary to make things run smoothly. The database side is not that bad actually. I created a custom type that is based on BlobType. The ougoign data on the other hand requires more boilerplate code if I don't want to do without type safety - which is one reason I picked MikroORM in the first place.
Additional context
I already made the rather trivial changes locally and can provide the necessary PR if that is helpful.