Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question

1 Answer

Why would you have duplications of the comment in the Post and Comment resources? Maybe just have a link in the Comment collection that points to the parent?

I'm actually dealing with the same issue. How to organize REST resources to take advantage of Mongo's strong points. Which approach did you end up going with?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.