<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: D0xzen</title>
    <description>The latest articles on DEV Community by D0xzen (@d0xzen).</description>
    <link>https://dev.to/d0xzen</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F261099%2Faecc07a8-c2bb-4c0e-9aff-d6e84b21f74b.png</url>
      <title>DEV Community: D0xzen</title>
      <link>https://dev.to/d0xzen</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/d0xzen"/>
    <language>en</language>
    <item>
      <title>Mongodb replace external id after $lookup </title>
      <dc:creator>D0xzen</dc:creator>
      <pubDate>Mon, 11 Nov 2019 10:43:52 +0000</pubDate>
      <link>https://dev.to/d0xzen/mongodb-replace-external-id-after-lookup-je7</link>
      <guid>https://dev.to/d0xzen/mongodb-replace-external-id-after-lookup-je7</guid>
      <description>&lt;p&gt;Hi, im going crazy...&lt;/p&gt;

&lt;p&gt;I want to replace the userId inside the comments with the real user after the $lookup, i tried in many ways, i tried to group but i cant really reach what i want&lt;/p&gt;

&lt;p&gt;This is my field inside the page collection:&lt;/p&gt;

&lt;pre&gt;

"comments" : [
        {
            "user_Id" : ObjectId("aaa"),
            "content" : "aaaa",
            "rep" : [
                {
                    "user_Id" : ObjectId("bbb"),
                    "comment" : "bbbb",
                },
                {
                    "user_Id" : ObjectId("ccc"),
                    "comment" : "cccc",
                }
            ]
        },
        {
            "user_Id" : ObjectId("ddd"),
            "content" : "ddd",
            "rep" : [ ]
        }
    ]

&lt;/pre&gt;

&lt;p&gt;Users collection:&lt;/p&gt;

&lt;pre&gt;

"users" : [
        {
            "_id" : ObjectId("aaa"),
            "name" : "user1",
            "email" : "test1@test.com",
        },
        {
            "_id" : ObjectId("bbb"),
            "username" : "user2",
            "email" : "test2@test.com",
          }
]

&lt;/pre&gt;

&lt;p&gt;What result i was looking for:&lt;/p&gt;

&lt;pre&gt;

"comments" : [
        {
            "user" : {
                "_id" : ObjectId("aaa"),
                "name" : "user1",
                "email" : "test1@test.com",
                }
            "content" : "aaaa",
            "rep" : [
                {
                    "userId" : {
            "_id" : ObjectId("bbb"),
            "username" : "user2",
            "email" : "test2@test.com",
          },
                    "comment" : "bbbb",
                },
                {
                    "user" : {
                               "_id" : ObjectId("aaa"),
                               "name" : "user1",
                "email" : "test1@test.com",
                },
                    "comment" : "cccc",
                }
            ]
        },
        {
            "user" : {
            "_id" : ObjectId("bbb"),
            "username" : "user2",
            "email" : "test2@test.com",
          },
            "content" : "ddd",
            "rep" : [ ]
        }
    ]


&lt;/pre&gt;

&lt;p&gt;What i did so far:&lt;/p&gt;

&lt;pre&gt;

db.pages.aggregate([
    { 
        $match: { _id: ObjectId('abcbc') }
    },
    {
        $project: {
            comments: 1,
        }
    },
    {
        $lookup:
            {
                from: 'users',
                localField: 'comments.user_Id',
                foreignField: '_id',
                as: 'users'
            }
    }
]).pretty()

&lt;/pre&gt;

&lt;p&gt;Right now it gives me the correct users but it give me comments with all my comments and users with all matched users how can i replace the userId with the real user object inside rep too?&lt;br&gt;
If i change inside the $lookup as into 'comments.user' it'll replace everything.&lt;/p&gt;

</description>
      <category>help</category>
    </item>
    <item>
      <title>Node backend and api calls same project</title>
      <dc:creator>D0xzen</dc:creator>
      <pubDate>Wed, 30 Oct 2019 07:57:39 +0000</pubDate>
      <link>https://dev.to/d0xzen/node-backend-and-api-calls-same-project-2a9b</link>
      <guid>https://dev.to/d0xzen/node-backend-and-api-calls-same-project-2a9b</guid>
      <description>&lt;p&gt;Hi guys, &lt;/p&gt;

&lt;p&gt;I fail to understand how after creating a BackEnd website with Node and Expressjs, if i want to make some functions async ex when someone like a post i want to call an API and return the response in json and append it to the html... &lt;/p&gt;

&lt;p&gt;I can create a route and threat it as a API call or i have to create a new project where i use only API calls? it's seems wrong to me cause i want only to allow some functions async...&lt;/p&gt;

</description>
      <category>node</category>
      <category>express</category>
    </item>
  </channel>
</rss>
