Skip to content

Enhance @DocumentReference to allow one-to-many style lookups #3798

Closed
@caspian-borison-by

Description

@caspian-borison-by

This is an amazing new feature and I definitely am looking forward to using it when 2.6 is released.

However, I have been playing around with it in some sandbox projects and (perhaps there is something I am missing, the documentation doesn't seem to address it?) but there appears to be one specific functional gap in the usage of it.

Assume I have:

class Book {
    @Id   
    String id;
    
    private String publisherId;
}

class Publisher {
   @Id
   String id;
   
   @ReadOnlyProperty
   @DocumentReference(lookup="{'publisherId': <this.id> ???}")
   List<Book> books;
}

Is it at all possible for the list of books to do a db.books.find({'publisherId': Publisher::id}) without storing a List bookIds on the Publisher class? Perhaps I am missing something from the documentation and this is already supported?

If not, then (I realize we're starting to get into foreign key relationships with Mongo which isn't the greatest thing), it does seem like a use case that would be beneficial to support if possible?

Thanks!

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions