contentful / vault

Easy persistence of Contentful data for Android over SQLite.
https://contentful.github.io/vault/
Apache License 2.0
85 stars 19 forks source link

How to do query selection with reference to other content type? #139

Closed kzotin closed 5 years ago

kzotin commented 6 years ago

Hi,

Can you advise please, is it possible to do use reference to another content type on query selection?

E.g. for the content model: Author - id, name Book - id, title, reference to author.

Currently, to select all books by given author, we select all books and filter afterward. With total amount of books growing, this becomes too slow.

vault.observe(Book::class.java)
            .all()
            .filter { book -> authorId == book.creator?.remoteId() }

Is it possible to do something like below?

vault.observe(Book::class.java)
            .where("${`Book$Fields`.CREATOR} = ?", authorId)
            .all()

Thanks in advance

mariobodemann commented 6 years ago

Hey,

that is a great question. Sadly I do not have a clear answer just now, and would need some time to find a good reply ...

Let me come back on this in lets say a week from now ...

Greetings, Mario

kzotin commented 6 years ago

hey @mariobodemann We've succeeded replacing Vault querying logic with Room Arch Component instead. It makes a huge difference, and it would be nice to have tight integration with Room on Vault side :)

Covered our journey with a blog post: https://blog.agilityscales.com/how-to-fix-orm-limitations-on-android-using-room-architecture-component-5925078ed920

kzotin commented 6 years ago

Please let me know if smth is not clear :)

mariobodemann commented 6 years ago

Hey,

so far it looks great. I will need to evaluate possible solutions and will see what we can do.

Thanks for your ongoing support....

anthony-seventhbeam commented 6 years ago

Any out of the box solution for this yet? I noticed #100 and by extension #68 from 2015 but I haven't been able to find any documentation regarding complex queries. At the moment I've been forced to filter on the observable which as mentioned above is terribly inefficient on large data sets.

mariobodemann commented 5 years ago

< closing this issue: currently there is no other way then the described one: filtering offline, without the help of vault and more complex queries >