Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forceObject when defineConfig #4881

Closed
wenerme opened this issue Oct 27, 2023 · 6 comments
Closed

forceObject when defineConfig #4881

wenerme opened this issue Oct 27, 2023 · 6 comments
Labels
enhancement New feature or request
Milestone

Comments

@wenerme
Copy link

wenerme commented Oct 27, 2023

Is your feature request related to a problem? Please describe.

I want to forceObject: true when defineConfig, I don't find a way to do this https://mikro-orm.io/docs/serializing#explicit-serialization . seems forceUndefined = skipNull, maybe can add some extra serialize options when defineConfig ?

Describe the solution you'd like

global forceObject config

Describe alternatives you've considered
property level option ?

Additional context

@wenerme wenerme added the enhancement New feature or request label Oct 27, 2023
@B4nan
Copy link
Member

B4nan commented Oct 27, 2023

That is a static method, it cannot respect any configuration, it does not have a way to read it.

@B4nan
Copy link
Member

B4nan commented Oct 29, 2023

I guess we could store the config reference on the entity prototype during discovery, and replace that with the right instance once the entity gets managed, that should cover most of the use cases.

@B4nan B4nan added this to the 6.0 milestone Oct 29, 2023
@wenerme
Copy link
Author

wenerme commented Oct 30, 2023

I guess we could store the config reference on the entity prototype during discovery, and replace that with the right instance once the entity gets managed, that should cover most of the use cases.

Dose this affect the multi em instance ?

@wenerme
Copy link
Author

wenerme commented Oct 30, 2023

That is a static method, it cannot respect any configuration, it does not have a way to read it.

How about use the context hook ? the static methdo try to read the config from context that match the current managed em ?

@B4nan
Copy link
Member

B4nan commented Oct 30, 2023

Dose this affect the multi em instance ?

Well, yes for not managed entities, but don't tell me you would like to have different serialization configs for those.

How about use the context hook ?

What's that? You mean the request context? That's an optional feature, I need a universal solution (and yet again, the callback to obtain a context is described in the config).

the static methdo try to read the config from context that match the current managed em ?

If an entity is managed, it already has the right EM link attached on it, and that is what would be always preferred. The problem is really just with not managed entities (and I think its safe to say those are not really serialized for most of the times).

B4nan added a commit that referenced this issue Oct 31, 2023
This option is now respected in implicit serialization too, as well as when serializing unpopulated collection items.

Closes #4881
@B4nan
Copy link
Member

B4nan commented Oct 31, 2023

Implemented in v6 via 9a4de46

@B4nan B4nan closed this as completed Oct 31, 2023
B4nan added a commit that referenced this issue Nov 2, 2023
This option is now respected in implicit serialization too, as well as when serializing unpopulated collection items.

Closes #4881
B4nan added a commit that referenced this issue Nov 5, 2023
This option is now respected in implicit serialization too, as well as when serializing unpopulated collection items.

Closes #4881
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants