私のchatsDBがこのデータで満たされているとしましょう:
{_id: "39e92f36-5d0f-44b7-8948-89be9b85bd08", fromPerson: "John Smith", toPerson: "Bob Smith", message: "Hey Buddy"}
{_id: "39e92f36-5d0f-44b7-8948-89be9b85bd08", fromPerson: "John Smith", toPerson: "Joe Smith", message: "Hi how you doing"}
{_id: "39e92f36-5d0f-44b7-8948-89be9b85bd08", fromPerson: "Tom Smith", toPerson: "Bob Smith", message: "Hello Again!"}
{_id: "39e92f36-5d0f-44b7-8948-89be9b85bd08", fromPerson: "Bob Smith", toPerson: "John Smith", message: "Hello Again!"}
この mongoDB にクエリを実行して、一意の結果セットを返したいと考えています。どうすればいいですか?
たとえば、SQL+php では次のようになります。
Select fromPerson Distinct from chatsDB;
私の今の考えは、ユーザーが話したことのある人の「chatUserList」を取得するために、from と to のリストを含むテンプレートをレンダリングすることです。