I have a scenario similar to as depicted below,
public class Post {
private int id;
private int postType;
private int score;
private User originalPoster;
private String title;
private String body;
private String tags;
}
public class Comment {
private int id;
private int postId;
private String text;
private int score;
private User userId;
}
public class User {
int id;
String displayName;
int score;
}
How do I model my MongoDb document/domain object?
My initial options are,
1) Have a separate Post and Comment collections and handle updates/retrievals hide behind my Rest Resource with possible duplicate of Comment in both Post and Comment.
2) Have a single Document Post and include everything in it and have only one Rest Resource? This will limit my url templates or need for complex data retrievals at MongoDB end.
Whether I should go with 1) or 2) or there is other approach where I can have flexibility of urltemplates and minimize the NoSQL interactions?