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
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.
The text was updated successfully, but these errors were encountered:
The goal is to work properly with entities that have properties of type
Uint8Array. Those properties should automatically be stored as binary
data and converted back to Uint8Array without specifying a type
(analogous to Buffer).
Also when converting entities to DTOs Uint8Array types should be kept
unchanged.
Closes#4418
Is your feature request related to a problem? Please describe.
Currently MikroORM works fine with Node.js
Buffer
. They are handled correctly in theEntityDTO
type returned by thetoObject
method. AlsoBlobType
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
andEntityDTO
. Since Node.jsBuffer
basically is aUint8Array
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.
The text was updated successfully, but these errors were encountered: