jonataslaw / get_server

A backend server that makes it possible to program with Flutter syntax and reuse existing code
Apache License 2.0
475 stars 42 forks source link

ORM for Get Server #36

Open smjxpro opened 3 years ago

smjxpro commented 3 years ago

Let me confess the fact that the GetX ecosystem is the most amazing thing that ever happened to Dart. With Fuchsia is on the horizon, it just feels right to have a unified full-stack Dart ecosystem. Get Server is the right step towards the backend of this unified full-stack ecosystem. However, despite it's too early, but I think the GetX ecosystem as whole needs to have a formal roadmap.

One important part of the modern backend is ORM. Which is currently lacking in Get Server or probably in any other server-side Dart framework. Yes, I know that @jonataslaw already planning to have one. But the purpose of creating this issue is specific to give some opinion on the implementation of the upcoming ORM which I am expecting to be available sooner than later.

Here's my thought: I have surfed enough of the backend frameworks from Laravel to Spring to Django to .NET for a while now. What I have found is that the ORMs on Django and .NET (Entity Framework) are two of the best there is. But in my observation, the Django ORM is tightly coupled to the Django framework. For example, you have to extend your model classes from models.Model class to ensure the ORM can detect changes. On the other hand, the .NET Entity Framework has something called Database Context. Which specifies all of the models that should be tracked. Models are simple classes without any extension. Therefore, in my opinion, I think it would be nice to have an ORM like Entity Framework in Get Server (Or maybe in the Flutter front-end GetX too to be able to communicate with in-app databases like SQLite). We already have the amazing get_cli tool which can be used to generate the database migration classes/files without build_runner and also to sync/update the database (much like manage.py and dotnet-ef tool).

Also, can we have a GitHub organization now? As GetX is growing rapidly?

Thanks for the amazing work.

mjablecnik commented 3 years ago

1) I thing that some ORM similar to Isar can be nice to have here. I am not .NET expert but isn't Isar similar to EntityFramework in .NET?? 2) And yes some GetX github organization can be useful when GetX is growing up and now have a lot of parts: State management, Dependency Injection, Route management, Server, CLI, etc.. And this all can be separated into different repositories because some people want to use only some parts in their projects.

smjxpro commented 3 years ago

I am not sure if we want code generation except the migration file. That will defeat the purpose of GetX. Which is no code generation, no build runner. And what I know is that Isar is database itself, not ORM. So no! Isar isn't helpful in this case I think.

CpdnCristiano commented 3 years ago

https://github.com/CpdnCristiano/mysql_simple_orm An orm without a code generator. Still in development

smjxpro commented 3 years ago

https://github.com/CpdnCristiano/mysql_simple_orm An orm without a code generator. Still in development

Nice work! But if you can find a way to get rid of manually defining the table schema, then it will be useful. The schema code can be generated as soon as we don't need to use them anywhere in our code except the ORM itself. Like I said, like EntityFramework. You just need to register your models as DbSets in the database context and you are done. Then you just use the database context object to do any database operations.

hosseinhadi commented 3 years ago

Have you ever tried the sqfentity package ? I were a .NET developer and searching for an ORM like EF. Finally I found this package to be useful and have an EF-like structure . Try it 👍

smjxpro commented 3 years ago

Have you ever tried the sqfentity package ? I were a .NET developer and searching for an ORM like EF. Finally I found this package to be useful and have an EF-like structure . Try it

Definitely not what I wish for. I am talking about code-first migration and without code-generation except for the actual migration file. Like how the get_cli generates code.