Code Monkey home page Code Monkey logo

Comments (11)

B4nan avatar B4nan commented on May 26, 2024 1

Let's keep this open, I'll first look if we can fix this as it should generally work the way you tried. It's just that many people really don't need this option, and generally speaking, you should rather not combine it with explicit constructor usage.

from mikro-orm.

B4nan avatar B4nan commented on May 26, 2024

This is caused by forceEntityConstructor, why do you want to use that? You shouldn't need this unless you use native private properties in your entity. Do you understand em.create uses the constructor regardless of this option? It's only about using constructor for creating managed entity instances.

from mikro-orm.

Sn-Kinos avatar Sn-Kinos commented on May 26, 2024

We are using it because of private properties in entity. Actually, We are using EntitySchema for our code conventions on NestJS. (model class, repository pattern, interface inject, etc.) Is it the only solution to solve this situation that disable forceEntityConstructor and avoid private properties?

from mikro-orm.

B4nan avatar B4nan commented on May 26, 2024

Private properties as in private TS keyword or native private properties as in #propName? This is only about the latter.

from mikro-orm.

Sn-Kinos avatar Sn-Kinos commented on May 26, 2024

I checked it again, the problem is readonly properties not private. I made new commit about it on reproduce repository.

from mikro-orm.

B4nan avatar B4nan commented on May 26, 2024

That flag has nothing to do with readonly modifier, you shouldnt need that in this test. Readonly modifier is a ts thing, it has no effect on runtime, and this flag has no type level effect.

from mikro-orm.

Sn-Kinos avatar Sn-Kinos commented on May 26, 2024

Thanks for feedback! I confused because of the original source code in companies. It occurs on property with =. I made new commit about it on reproduce repository, but I can figure out the reason is Object.create.
Then how can we solve that? On the original, we are using it like logger = new Logger('User'); but in this case this.logger is undefined.

from mikro-orm.

B4nan avatar B4nan commented on May 26, 2024

You can use @OnInit hook

https://mikro-orm.io/docs/events#hooks

from mikro-orm.

Sn-Kinos avatar Sn-Kinos commented on May 26, 2024

I got it. For the same reason, all of method in class with arrow function are undefined too. I should change them all... 😵‍💫

from mikro-orm.

B4nan avatar B4nan commented on May 26, 2024

Do you have an actual reason to use arrow functions there? Turn them into actual methods and this problem disappears too.

from mikro-orm.

Sn-Kinos avatar Sn-Kinos commented on May 26, 2024

Yeah, It didn't have an actual reason about it... Just the reason it uses less lines.

isDisabled = () => this.status === 'progress';

isDisabled() {
  return this.status === 'progress';
}

Thanks for the reply!

from mikro-orm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.