Post

O Post já terá os seus atributos + o comentário e o autor do post.

Para que Posts fiquem referenciados no User conforme pode ser visto no UML, criaremos no User uma lista de posts (public), com a anotação @DBRef(lazy = true).

@Document(collection = "posts") 
@Getter 
@Setter 
@NoArgsConstructor 
public class Post {
    @Id
    private String id;
    private Instant moment;
    private String title;
    private String body;
    
    private Author author;
    
    @Setter(AccessLevel.NONE)
    private List<Comment> comments = new ArrayList<>();
    
    public Post(String id, Instant moment, String title, String body, Author author) {
        this.id = id;
        this.moment = moment;
        this.title = title;
        this.body = body;
        this.author = author;
    }
}

Criar também, PostRepository.

Atualizado