Stack Overflow に似たモデルのアプリケーションを開発しています (質問/回答など...) C#/ASP.net MVC を使用した NoSQL フォーラム アプリケーションのモデル化
モデルは次のようになります(簡略化)
class Question
{
public string Title { get; set; }
public string Body { get; set; }
public DateTime DateCreated { get; set; }
public string UserName { get; set; }
public List<Answer> Replies { get; set; }
}
class Answer
{
public string Body { get; set; }
public DateTime DateCreated { get; set; }
public string UserName { get; set; }
}
つまり、私のドキュメントは、「回答」が埋め込まれた 1 つのドキュメントにすぎません。
このアプローチ用にリポジトリを設計しようとしています。
2 つの別々のリポジトリが必要ですか? 例えば:
interface IQuestionRepository
{
void PutQuestion(Question question);
Question GetQuestion(string questionID);
}
interface IAnswerRepository
{
void PutAnswer(string questionID, Answer Answer);
Answer GetAnswer(string answerID);
}
またはこのようなもの:
interface IPostRepository
{
void PutQuestion(Question question);
Question GetQuestion(string questionID);
void PutAnswer(string questionID, Answer Answer);
Answer GetAnswer(string answerID);
}