How to insert a @N1qlJoin field? [Spring Data Couchbase]

Hey there,
I must say that the @N1qlJoin concept is not covered well enough.
The documentation says very little about it.

My problem is that I would like to keep the field “author” in a “Comment” object.
The “author” field is of class “Author” of course.
So the “Comment” class looks something like this:

class Comment {
          // Some fields..
         @N1qlJoin(on = "lks.author.email=rks.email")
         private Author author;
}

I am also using Spring Data Rest.
The problem is on how to insert the comment object so that I will only need to specify the author id (email)?

Thanks in advance.

The doc in the repo assumes you have an Author doc, with a name field. Also, there are Address and Book docs. That name field in the Author doc is then used to join to the authorName field in the Book doc, and with the name field in the Address doc.

Your Comment class could perhaps have a field named name. That name could then be joined to the Author (assuming Author contains a field named email) something like:

@Document     
public class Comment {
      @Id   
      String id;
       
      String name;

      @N1qlJoin(on=lks.name=rks.email)
      Author author;
    }

When you insert a new comment, you just need to fill in the name field. So - you are joining pretty much like you’d join tables in sql - the join field is repeated in the 2 documents.