pinchbv / floor

The typesafe, reactive, and lightweight SQLite abstraction for your Flutter applications
https://pinchbv.github.io/floor/
Apache License 2.0
954 stars 191 forks source link

Plans to support OneToOne, OneToMany, ManyToOne and ManyToMany #314

Closed cassioseffrin closed 4 years ago

cassioseffrin commented 4 years ago

Hello,

There is any plan to allow Floor to support OneToOne, OneToMany, ManyToOne and ManyToMany relationships?

Maybe you can take a look at JaguarORM: https://github.com/Jaguar-dart/jaguar_orm

mqus commented 4 years ago

At least a part of what you possibly want are ForeignKeys in the @Entity annotation. If you want to see how they work in detail you can also look at the same feature in androids room library. There should be many uses in android apps in the wild which you can look at, I don't have any specific one in mind right now though.

What we should probably consider for implementing is @Relation, but it seems to be pretty complex (but doable).

mqus commented 4 years ago

Just to be sure though, what is your use case for this, what do you want to do?

cassioseffrin commented 4 years ago

Yes it's very complex in fact. There are a lot of dependencies when these kind of mapping are made, including lazy load and eager load and a bunch of configs. The collections needs to have configurations otherwise the queries becoming very heavy to process in database.

The big advantages of these kind of mapping are provide to programmers unlimited capabilities and zero SQL native queries. All the data access will be separated in persistence layer. The code become more concise and easy to maintain.

But I understand your point. If the idea is to keep Floor more simpler may it's not the case. I have made a lot o researches for ORM in dart. Dart don't have a killer ORM library like Java has the Hibernate, SpringData,JPA or even JDBC. Obviously each language has it's own goals and Dart and Java seems to crave for different proposes.

Until now I made my mind to follow with Floor. It's been fulfilling my projects needs. Except these mappings that I will continue to recommend. For my experience these mappings will make Floor the pretty best ORM in dart. And may you can take a look in Jaguar ORM instead of hibernate cause it's simpler, written in dart and follows the same philosophies. I can guarantee (hibernate) is the market standard, and big platforms (like .NET has the same implementations) are using the same nomenclature and concepts.

mqus commented 4 years ago

Closing this as a duplicate of #47 which tracks relations

BrianMwas commented 3 years ago

Hello,

There is any plan to allow Floor to support OneToOne, OneToMany, ManyToOne and ManyToMany relationships?

Maybe you can take a look at JaguarORM: https://github.com/Jaguar-dart/jaguar_orm

Hi can we use jaguar ORM with floor with the same db?

mqus commented 3 years ago

Short answer: no. How would this work anyways? floors streams can only track changes made by floor, and this completely ignores database layout decisions which might be different and defining which part defines/creates the schema and the nightmare of keeping both synchronized.