It makes the guys from JavaScript who know Java smile as well. I think those decorators are a bit too much. Newer ORMs like Prisma use a more elegant approach.
When I try to add @Column decorator to a "declare" I receive an error "Decorators are not valid here". If I change the property to "public name!: string" it works. But this way I cannot override Model properties such as id, createdAt and updatedAt. I'm not using the example repository. Was trying to add sequelize to an existing typescript project
Did you use sequelize-typescript package? Also, did you set "experimentalDecorators": true, "emitDecoratorMetadata": true in "compilerOptions" in tsconfig.json?
@@alexrusin I did both of them. It seems like a project specific configuration that I did not know about. When I tried the tutorial steps on a new project it worked like a charm. But on this specific project it shows me this error when I try to use declare with the decorator.
when i try to connect two tables with HasMany and ForeignKey, I get errors like "No overload matches this call" and "Types of construct signatures are incompatible." The code is the same. Edit: fix in the comments
Migrations are actually in a different project github.com/alexrusin/travel-api-db-migration-service Sometimes it makes sense to create a separate service for migrations so you don't run migrations every time you deploy your project, especially when you are working with microservices.
Interesting. I'm going to test it on node 20 when I get a chance. You did put "experimentalDecorators": true, "emitDecoratorMetadata": true in your tsconfig.json, right?
@@alexrusin That is what esbuild was throwing on. I got around it by using swc instead of esbuild. Issue is not with the core tutorial itself, but some of the technologies.
The use of these decorators will most likely make guys from Java (like myself) smile. Thanks for the update.
It makes the guys from JavaScript who know Java smile as well. I think those decorators are a bit too much. Newer ORMs like Prisma use a more elegant approach.
straightforward and to the point. Loving this Sequelize tutorial
Thank you.
Another solid tutorial. I'm definitely subscribing. Please keep 'em up!
Thanks, will do!
where can i get the project repository?
You can find it right here: github.com/alexrusin/travel-api-travels-service
When I try to add @Column decorator to a "declare" I receive an error "Decorators are not valid here". If I change the property to "public name!: string" it works. But this way I cannot override Model properties such as id, createdAt and updatedAt.
I'm not using the example repository. Was trying to add sequelize to an existing typescript project
Did you use sequelize-typescript package? Also, did you set "experimentalDecorators": true, "emitDecoratorMetadata": true in "compilerOptions" in tsconfig.json?
@@alexrusin I did both of them. It seems like a project specific configuration that I did not know about. When I tried the tutorial steps on a new project it worked like a charm.
But on this specific project it shows me this error when I try to use declare with the decorator.
@@rodrigosilva1302 were you able to pinpoint the exact reason?
when i try to connect two tables with HasMany and ForeignKey, I get errors like "No overload matches this call" and "Types of construct signatures are incompatible." The code is the same.
Edit: fix in the comments
The issue was that "Model" was being imported from "sequelize" and not "sequelize-typescript". Anyway, thanks for the tutorial, keep it up!
How did you run migration?
Migrations are actually in a different project github.com/alexrusin/travel-api-db-migration-service
Sometimes it makes sense to create a separate service for migrations so you don't run migrations every time you deploy your project, especially when you are working with microservices.
Seems like this is not yet supported on current LTS. ESBuild throws a bunch of errors about lacking decorator support for node 20
Interesting. I'm going to test it on node 20 when I get a chance. You did put "experimentalDecorators": true,
"emitDecoratorMetadata": true in your tsconfig.json, right?
@@alexrusin That is what esbuild was throwing on. I got around it by using swc instead of esbuild. Issue is not with the core tutorial itself, but some of the technologies.