所以可以说我的聊天数据库充满了这些数据:
{_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”。