小编use*_*798的帖子

如何只获取mongoDB和meteor中的不同值?

那么就说我的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!"}
Run Code Online (Sandbox Code Playgroud)

我想通过查询这个mongoDB返回一组独特的结果.我该怎么做呢?

例如在SQL + php中:

Select fromPerson Distinct from chatsDB;

我现在的想法是渲染模板,其中包含来自和来自人的列表,以获得用户与之交谈过的人的"chatUserList".

javascript chat mongodb meteor

6
推荐指数
2
解决办法
5145
查看次数

标签 统计

chat ×1

javascript ×1

meteor ×1

mongodb ×1