Comments (11)
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.
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.
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.
Private properties as in private
TS keyword or native private properties as in #propName
? This is only about the latter.
from mikro-orm.
I checked it again, the problem is readonly
properties not private
. I made new commit about it on reproduce repository.
from mikro-orm.
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.
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.
You can use @OnInit
hook
https://mikro-orm.io/docs/events#hooks
from mikro-orm.
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.
Do you have an actual reason to use arrow functions there? Turn them into actual methods and this problem disappears too.
from mikro-orm.
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)
- Assigning a customType and flushing to database does not escape returning values HOT 1
- Join gets removed when the populate doesn't include the nested orderBy relation
- Migration schema diffing fails with deleteRule: 'set null ("...")'
- docs: Multiple schemas, but not all schemas
- Mongodb driver doesn't detect deep updates HOT 1
- Utils.copy() does not maintain the new instance metadata
- Populate invalid cast date
- Allow hydration of virtual properties in embeddables HOT 14
- [Bug]: Loaded type does not catch missing population types when Collection is in `populate` array HOT 7
- I can't use MySQL driver in MariaDB
- mikro-orm migration:fresh --drop-db runs migrations against wrong db
- Join column named after children when using @ManyToMany on STI parent entity HOT 9
- 'longblob' property generates `varchar(255)` in the snapshot HOT 3
- Timezone issue
- Support PostgreSQL parameterized queries HOT 1
- Fetching partial entities with MongoDB does not work
- findOne/findOneOrFail should work without where param or with empty where param HOT 1
- SyntaxErrorException: [...] - syntax error at or near "<"
- MetadataError: Source file '$' not found. Check your 'entitiesTs' option [...]
- Explicit serialization throws error when serializing new embeddable
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mikro-orm.