MongoDB查询从用户参与的对话中获取消息的光标?

时间:2016-08-17 01:45:04

标签: mongodb

我如何获得a参与的所有邮件的光标,并将a转换为完整的用户名,如果它是alex

会话

{ "_id" : "CyiJgeNmxcfRNbnub", "_participants" : [ "a", "b" ] }
{ "_id" : "naZXvcdWdo4QbFDDa", "_participants" : [ "b", "c" ] }
{ "_id" : "ADGuA8PpCS9XKHPoE", "_participants" : [ "a", "c" ] }

消息

{ "_id" : "9MRBdb4QhoX4nXKtw", "body" : "Asdf", "conversationId" : "CyiJgeNmxcfRNbnub",    "userId" : "a") }
{ "_id" : "sQYxBrmw69pttCs42", "body" : "Yo", "conversationId" : "naZXvcdWdo4QbFDDa",   "userId" : "b") }
{ "_id" : "Hf2vmS54TZbvGbLXT", "body" : "hi", "conversationId" : "ADGuA8PpCS9XKHPoE",   "userId" : "c") }

预期结果(userId是发件人的userId)

{ "_id" : "9MRBdb4QhoX4nXKtw", "body" : "Asdf", "conversationId" : "CyiJgeNmxcfRNbnub",    "userId" : "a") }
{ "_id" : "Hf2vmS54TZbvGbLXT", "body" : "hi", "conversationId" : "ADGuA8PpCS9XKHPoE",   "userId" : "c") }

0 个答案:

没有答案