-
-
Notifications
You must be signed in to change notification settings - Fork 492
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
docs: add Ts.ED example usage #2587
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
few notes:
- missing link from sidebar
- please follow the code style this project uses (e.g. spaces in imports, trailing commas, single quotes ...)
- i would very much like to not suggest using
__dirname
in folder based discovery, it can easily break things - i would rather have
orm
property thanconnection
in that example, this "typeorm style" seems wrong, it is not a connection instance in the mikro orm context - i dont like that you alias the
Property
decorator toColumn
, we are in the MikroORM docs, so please alias your property decorator and keep the ORM one as is to reduce confusion - would be good to verify things work with v5, the release will come soon so if we should add things like this to the docs, they should all work with v5 already
Hello @B4nan thank for your review, I'll take a time to discuss with the author of this plugin to get your feedback.
I don't totally agree, because this decorator is also necessary to properly take advantage of the integration of our two frameworks. We are precisely on a page that talks about an integration between Ts.ED and mikro ORM. It's as if on my documentation page, I presented our annotations without describing yours. (https://tsed.io/tutorials/mikroorm.html) In our example, there is nothing confusing because the decorators are clearly imported via their original packages. We can add split the example in two part, if it's fine for your:
import {Entity, Property, PrimaryKey, Property as Column} from "@mikro-orm/core";
@Entity()
export class User {
@PrimaryKey()
id: number;
@Column()
firstName: string;
@Column()
lastName: string;
@Column()
age: number;
} We can also add Ts.ED decorators in order to reuse the model at controller level (mapping, validation and generation of the OS3 Spec aka Swagger): import {Property, MaxLength, Required} from "@tsed/schema";
import {Entity, Property, PrimaryKey, Property as Column} from "@mikro-orm/core";
@Entity()
export class User {
@PrimaryKey()
@Property()
id: number;
@Column()
@MaxLength(100)
@Required()
firstName: string;
@Column()
@MaxLength(100)
@Required()
lastName: string;
@Column()
@Mininum(0)
@Maximum(100)
age: number;
}
I'm not a Mikro ORM user so I don't know what are the change about the v5. I let the plugin author to answer to this point. @derevnjuk I think the I'll fix the other points :) See you |
I understand your point of view, but this is MikroORM docs we are talking about, so aliasing its decorators is a no-go for me - this would be the only place where we do such thing. My point is you should alias the Ts.ED decorator, as in the context of MikroORM docs, it is a 3rd party dependency.
If you are looking at MikroORM docs - where every single page except this one would use |
Ha ok you have a property decorator. Required/MaxLength are a problem also? |
I know it is not alias for my decorator. I am talking about aliasing my decorator when importing it. |
haaa ok, really sorry for this confusing things, I haven't written the original example, and I haven't seen that. |
07c2909
to
96ad5fe
Compare
Ok, I pushed all mandatory fixes:
For the last point, there is migration note somewhere ? But regarding the Mikro ORM code used in this module, the risk seems to be limited. You can see the code here: https://github.com/tsedio/tsed/tree/production/packages/orm/mikro-orm/src/services . As I understand, the module create the Mikro ORM instance and provide a way to inject Orm/Em instance. Tell me if you have more details for me or for @derevnjuk :) See you |
No issues have been encountered while testing this with v5.0.0-rc.0, especially when we speak about the main functionality. However, I have noticed you changed the Before: orm.em.fork(true, true); After: orm.em.fork({ clear: true, useContext: true }); As a workaround, we can call this method in the following way: (orm.em.fork as (
clearOrForkOptions?: boolean | {clear?: boolean; useContext?: boolean},
useContext?: boolean
) => EntityManager)({clear: true, useContext: true}, true); |
96ad5fe
to
7035f5b
Compare
Hello @B4nan This PR will support mikro-orm v5 officially: tsedio/tsed#1950 The documentation is up to date! We should be good and waiting for your last ones if there are any :-) |
|
||
## Installation | ||
|
||
Easiest way to integrate MikroORM to Ts.ED is via [`@tsed/mikro-orm` module](https://tsed.io/tutorials/mikroorm.html). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should be some clear note that there is possibly more up to date version of this recipe in the tsed docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't necessary. The API have changed on our side. The latest changes is internal and your documentation point to the latest release. It shouldn't be a problem for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@derevnjuk can you confirm this point ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, I believe this is mostly a copy paste from your docs, if that's the true, I would like to have a link to the source as that will be usually most up to date. And this should be explicitly stated, I know there is a link already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. @B4nan Do you have a formulation or an example of a sentence that would suit you in this case?
As I don't see anything equivalent on other pages such as Nest.js and Admin.js, I wouldn't want to put anything :)
Suggestion:
::: tip Note
The documentation presented on this page is taken from the Ts.ED site. The latest updates to this example can be found directly on the [`@tsed/mikro-orm` module](https://tsed.io/tutorials/mikroorm.html) page.
:::
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nest.js guide has such link in the opposite direction, as the @mikro-orm/nestjs
is our package. I'd imagine something like that.
06e4c83
to
cb4d2db
Compare
Hello :)
This PR is here to add the MikroOrm integration with our framework Ts.ED. Our integration is really recent but we'll improve the module and add more feature in future!
Tell me if any change is required :)
See you and great job for your ORM!
Romain