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

Why use Object.assign? #4

Open
vedantroy opened this issue Apr 19, 2023 · 1 comment
Open

Why use Object.assign? #4

vedantroy opened this issue Apr 19, 2023 · 1 comment

Comments

@vedantroy
Copy link

Is there any reason this code does the following:

     request.mikroORM = {
        orm: Object.assign({}, this.mikroORM.orm)
      }

instead of:

     request.mikroORM = {
        orm: this.mikroORM.orm
      }

or even just:

request.mikroORM = this.mikroORM

Presumably Object.assign is a shallow copy anyways?

@serdnam
Copy link
Owner

serdnam commented Apr 19, 2023

I did it this way so that the mikroORM attribute on the request object is not the same reference as the one on the Fastify object itself, I thought that could probably be problematic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants