SHARE
TWEET

Untitled

a guest Apr 20th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. db.A.aggregate([
  2. {
  3.     $project: {
  4.         B_fk: {
  5.           $map: {
  6.              input: {
  7.                   $map: {
  8.                       input:"$bid",
  9.                       in: {
  10.                            $arrayElemAt: [{$objectToArray: "$$this"}, 1]
  11.                       },
  12.                   }
  13.              },
  14.              in: "$$this.v"}
  15.         },
  16.     }
  17. },
  18. {
  19.     $lookup: {
  20.         from:"B",
  21.         localField:"B_fk",
  22.         foreignField:"_id",
  23.         as:"B"
  24.     }
  25. ])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top