0

How would I get the cursor of all of the messages that a has participated in and transform a into the full username if it is it alex?

conversations

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

messages

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

expected result (userId is userId of sender)

{ "_id" : "9MRBdb4QhoX4nXKtw", "body" : "Asdf", "conversationId" : "CyiJgeNmxcfRNbnub",    "userId" : "a") }
{ "_id" : "Hf2vmS54TZbvGbLXT", "body" : "hi", "conversationId" : "ADGuA8PpCS9XKHPoE",   "userId" : "c") }
atkayla
  • 8,143
  • 17
  • 72
  • 132
  • 2
    http://stackoverflow.com/questions/2350495/how-do-i-perform-the-sql-join-equivalent-in-mongodb – Wake Aug 17 '16 at 01:52
  • 2
    @Wake Thank you so much! I didn't know what to search to find a similar question. – atkayla Aug 17 '16 at 01:53

0 Answers0