<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Lucas Yuri on Medium]]></title>
        <description><![CDATA[Stories by Lucas Yuri on Medium]]></description>
        <link>https://medium.com/@lucas-yuri?source=rss-b8ec5e614113------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0H0oUmLbKTTMW8n2u1HkSw.jpeg</url>
            <title>Stories by Lucas Yuri on Medium</title>
            <link>https://medium.com/@lucas-yuri?source=rss-b8ec5e614113------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 23:02:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lucas-yuri/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Using Slack to remind open GitLab MR’s]]></title>
            <link>https://lucas-yuri.medium.com/using-slack-to-reminder-open-gitlab-mrs-82d1b3c06a0d?source=rss-b8ec5e614113------2</link>
            <guid isPermaLink="false">https://medium.com/p/82d1b3c06a0d</guid>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[javascript-development]]></category>
            <category><![CDATA[slack-tips-and-tricks]]></category>
            <dc:creator><![CDATA[Lucas Yuri]]></dc:creator>
            <pubDate>Fri, 24 Sep 2021 22:17:57 GMT</pubDate>
            <atom:updated>2021-09-25T21:31:47.712Z</atom:updated>
            <content:encoded><![CDATA[<p>At the end of this Article you’ll know how to use Slack to send periodic messages with all opened GitLab MR’s of your team. <em>You’ll receive a message like that:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c3U4HuyqRkvSeA1anGyOFQ.png" /><figcaption>Slack message with all opened MR’s at GitLab</figcaption></figure><blockquote><em>This is very useful when you have </em><strong><em>a team with more than 5/6 developers</em></strong><em> and has lots of MR’s. You could </em><strong><em>schedule</em></strong><em> this integration to send messages at your team slack channel at the </em><strong><em>beginning and at the end of workday</em></strong><em>. So, they will be </em><strong><em>remind</em></strong><em> to review incoming code changes, </em><strong><em>making your team more agile</em></strong><em>.</em></blockquote><h4>Clone the repository</h4><p>You will use the repository bellow:</p><p><a href="https://github.com/Luryy/Merge-Request-Slack-Reminder">GitHub - Luryy/Merge-Request-Slack-Reminder: Project to run a scheduled job that send to a specific slack channel a list of opened MR&#39;s of your GITLAB project group</a></p><p>Follow the instructions present at README to clone it, and at this article I’ll show how to setup to your environment.</p><p>To make this integration, we’ll use <a href="https://docs.gitlab.com/ee/api/">GitLab API</a>, <a href="https://api.slack.com/messaging/webhooks">Slack Webhook</a> and <a href="https://www.npmjs.com/package/node-cron">node-cron</a>.</p><p>Now that you have cloned the repository above, you only need to configure the <strong><em>.env </em></strong>file to access the services above.</p><h4>GitLab</h4><p>We need to set 3 variables at <strong><em>.env </em></strong>to configure GitLab (<strong><em>GITLAB_URL</em></strong>, <strong><em>GITLAB_PROJECT_ACCESS_TOKEN</em></strong>, <strong><em>GITLAB_PROJECT_ID</em></strong>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LlVT4wewI3Mal8Nn7I2ieA.png" /></figure><p>To get your <strong><em>GITLAB_PROJECT_ID</em></strong>, you should go to your project/group page and get its ID. <em>You can see the number 13492402 at screenshot.</em></p><p>If you don’t use a GitLab instance, your <strong><em>GITLAB_URL </em></strong>will be <em>https://gitlab.com/api/v4/</em>.<br>If you use a GitLab instace, your <strong><em>GITLAB_URL </em></strong>will be <em>https://gitlab.example.com/api/v4/ </em>(only check your GitLab URL and add /api/v4/ )</p><p>At least, to set <strong><em>GITLAB_PROJECT_ACCESS_TOKEN</em></strong>, you should generate a GitLab access token.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eN6yfdaYG_JRBxaAfz0n4g.png" /></figure><p>To do that, go to <em>user setting </em>and<em> access tokens </em>at your GitLab Account.</p><p><em>Set a </em><strong><em>name</em></strong> to your token and select <strong><em>read_api</em></strong><em> </em>check-box.<br>Then click at <strong><em>Create personal access token</em></strong><em> </em>button.</p><p>Your token will be created.</p><p>Now you have all necessary configuration to access GitLab API, it’s time to see how to allow slack integration.</p><h4>Slack</h4><p>We need to setup 2 <strong><em>.env </em></strong>variables (<strong><em>SLACK_WEBHOOK</em></strong>, <strong><em>SLACK_CHANNEL</em></strong>)</p><p><strong><em>SLACK_CHANNEL </em></strong>is the channel name of your Slack workspace</p><p>To get your <strong><em>SLACK_WEBHOOK</em></strong>, you should configure <strong>Incoming Webhooks</strong> App at your Slack workspace</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1r4en7hyiJZ0Carg5bcKTw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hm7vzKLgBqEiALdlK5mHOA.png" /></figure><p>You should find this App at your slack workspace and click <em>Add to Slack</em> and configure it.</p><p>Then you will receive an <strong>Webhook URL</strong>, just copy that to <em>SLACK_WEBHOOK </em>variable and now you will be able to integrate with Slack.</p><p>Now we are able to get GitLab info and send it to Slack. Finally, let’s configure the frequency of these messages.</p><h4>Node-Cron</h4><p>To configure the frequency of those messages, we need to setup 2 <strong><em>.env </em></strong>variables (<strong><em>CRON_TASK_INTERVAL</em></strong>, <strong><em>TASK_INTERVAL_TIMEZONE</em></strong>).</p><p><strong><em>CRON_TASK_INTERVAL </em></strong>will be when you want to receive the reminder, the sintax is based on <a href="https://www.gnu.org/software/mcron/manual/html_node/Crontab-file.html">GNU Crontab</a>.<br><strong><em>TASK_INTERVAL_TIMEZONE </em></strong>will be the timezone of the task, you can check the option available at <a href="https://momentjs.com/timezone">moment-timezone</a>.</p><blockquote>As example, if you set:<br><strong>CRON_TASK_INTERVAL</strong>=<strong>0 9 * * 1–5</strong><br><strong>TASK_INTERVAL_TIMEZONE</strong>=<strong>America/Sao_Paulo<br></strong><em>Every 9AM at workdays, slack will notify with opened MR’s</em></blockquote><h4>That’s all folks</h4><p>Now you have all needed configuration, just deploy that reminder application wherever you prefer and comment here if it helped to improve your team.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82d1b3c06a0d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Node.JS Streams — File]]></title>
            <link>https://lucas-yuri.medium.com/node-js-streams-file-98f0487605dd?source=rss-b8ec5e614113------2</link>
            <guid isPermaLink="false">https://medium.com/p/98f0487605dd</guid>
            <category><![CDATA[nodejs-stream]]></category>
            <category><![CDATA[node-js-tutorial]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Lucas Yuri]]></dc:creator>
            <pubDate>Mon, 22 Mar 2021 20:50:19 GMT</pubDate>
            <atom:updated>2021-03-22T20:50:19.253Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Pjizyd4TrnDaHlhbW0YKUA.png" /></figure><p>In this tutorial I’ll show different ways to <strong>response files</strong> to your client from your back-end, and explain the benefits of use <strong>Node.JS steams</strong>.</p><p>First, we’ll see the response using only “send&quot; method. Then we can compare it with the stream method.</p><p>You could check all used <a href="https://github.com/Luryy/NodeJS-Streams-Files-Implementation">code here</a>.</p><p>📢<strong> Important Informations:</strong></p><p>System Info: <em>*this information is about my system, where I run the tests</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*yIOl8g-TbgezW2PqUVzdUQ.png" /></figure><p>File Info:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/1*89-OEu6SyCpINX586DpUTQ.png" /></figure><p><em>This is the information about the file that will be send to the client.</em></p><p>File Size: <strong>147MB</strong></p><p>📏 <strong>Monitoring memory usage</strong></p><p>To see the behavior of our application, well’ll <strong>monitor the usage of memory</strong>. To do that, every 5 seconds the total of memory usage will be logged at our console.</p><p>We could do that using this code:</p><pre>const <strong>processUsage</strong> = process.memoryUsage();<br>const <strong>totalUsedMemoryInMb</strong> = Math.floor(<em>processUsage</em>.<em>rss</em> / (1024 * 1024));<br>console.log(`<strong><em>Used Memory: ${totalUsedMemoryInMb} MB</em></strong><em>`</em>);</pre><p>This is the result of the code above:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*dZ7ZoQ-I054e3b2ncy56yg.png" /></figure><p>As you can see, <strong>40MB</strong> is the <strong>base consumption</strong> of application when startup. <em>By the way,</em> n<em>ote that we are using typescript and development mode, when we build the application this consumption will decrease. But for our test purpose, it’s ok, we just need to </em><strong><em>guarantee that all test will be run at same environment</em></strong><em>.</em></p><p>📤 <strong>Making the requests</strong></p><p><strong><em>Send method</em></strong></p><p>First let’s analyse using the <strong>res.<em>send</em></strong><em> </em>method to response our file. You can see the implementation:</p><pre>app.get(&#39;<strong>/send-sync</strong>&#39;, (<em>req</em>, <em>res</em>) =&gt; {<br> const <strong>filePath</strong> = resolve(__dirname, &#39;..&#39;, &#39;upload&#39;, &#39;ex.mp4&#39;);<br> <strong><em>fs.readFile</em></strong>(filePath, (<em>err</em>, <em>data</em>) =&gt; {<br>   <strong><em>res</em>.send(<em>data</em>);</strong><br> });<br>}</pre><p>This is an inefficient way to send files, because <strong>this loads the entire file into application memory </strong>before response to the client. If we make 10 requests to this route, the file will be loaded 10 times in memory, even thought it’s the same file.</p><p>We can see this happening at the screenshot below. I opened <strong>10 tabs</strong> at my browser wheres load a html that <strong>renders the file using the route above.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qq6ssvd8hJlk8D-T5NOsrA.png" /></figure><p>As you can see, the consumption of <strong>memory increased strongly</strong>, using a total of <strong>880 MB</strong>. <em>Remember that the video has 140MB!</em> So, if you want <strong>scalability</strong>, this certainly <strong>not</strong> the best implementation to use.</p><p><strong><em>Streams method</em></strong></p><p>We know that Node make things in <strong>small chunks</strong>. To response information to the client, it do that sending <strong>little pieces of data</strong> without storage in memory. We could use this approach with our file too,<strong> sending the file directly of our file system</strong> in small pieces. This process is called <strong>Streaming</strong>.</p><p>You can see the implementation of this approach:</p><pre>app.get(&#39;<strong>/stream</strong>&#39;, (<em>req</em>, <em>res</em>) =&gt; {<br> const { range } = <em>req</em>.headers;<br> const filePath = resolve(__dirname, &#39;..&#39;, &#39;upload&#39;, &#39;ex.mp4&#39;);<br> const { <em>size</em>: fileSize } = <em>fs</em>.statSync(filePath);</pre><pre> const <strong>start</strong> = <em>Number</em>(range?.replace(/\D/g, &#39;&#39;)) || 0;<br> const <strong>CHUNK_SIZE</strong> = 1000000;<br> const <strong>end</strong> = Math.min(start + CHUNK_SIZE, fileSize - 1);</pre><pre> const <strong>headers</strong> = {<br>   &#39;Content-Range&#39;: `bytes ${start}-${end}/${fileSize}`,<br>   &#39;Accept-Ranges&#39;: &#39;bytes&#39;,<br>   &#39;Content-Type&#39;: &#39;video/mp4&#39;,<br>   &#39;Content-Length&#39;: CHUNK_SIZE,<br> };</pre><pre><em> </em><strong><em>res.writeHead</em></strong>(206, headers);</pre><pre> const <strong>fileStreams</strong> = <em>fs</em>.createReadStream(filePath, { start, end });<br> <strong><em>fileStreams.pipe</em></strong>(<em>res</em>);<br>}</pre><p>Briefly, the code <strong>get information about the request</strong> to know witch part of the file should response. Then start to <strong>read this part of the file</strong> and <strong>simultaneously sending to client</strong>.</p><p>To test it, opened 10 tabs again:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MgnWUzjmtrY9i3ttQ2HGcA.png" /></figure><p>You can see the big difference of memory consumption. With the same number of requests, now it’s <strong>almost imperceptible the usage of memory</strong>. This happens because the <strong>file system doesn’t use the memory</strong> to read the file.</p><p><strong><em>Streams using sendFile method</em></strong></p><p>Alternatively we can use <strong><em>sendFile </em></strong>method<strong><em> </em></strong>to response the file using stream approach. It works similar at the method explained above, but has slight difference in usability, mainly due customization.</p><p>You could check the code below:</p><pre>app.get(&#39;<strong>/send-file</strong>&#39;, (<em>req</em>, <em>res</em>) =&gt; {<br> const <strong>filePath</strong> = resolve(__dirname, &#39;..&#39;, &#39;upload&#39;, &#39;ex.mp4&#39;);<br> return <strong><em>res.sendFile</em></strong>(filePath);<br>}</pre><p>The implementation is simpler and perform similar as “<em>stream hard implementation</em>”. You could see at test:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dQNMM0zJqBxd4LEAV9_G4Q.png" /></figure><p>It performs similar as “<em>stream hard method</em>”, the <strong>memory usage is almost the same</strong>. And to scale your application, you can use this simple implementation without loose performance.</p><p>As I said, this two implementations have slight differences. If want an article about that, comment below 😁</p><p><strong>You can run those tests too!</strong> Check the <strong>repository</strong> below and run! At README you have the full instructions to make it!</p><p><a href="https://github.com/Luryy/NodeJS-Streams-Files-Implementation">Luryy/NodeJS-Streams-Files-Implementation</a></p><p>Connect with me:</p><p><a href="https://www.linkedin.com/in/lucas-yuri/">Linkedin</a></p><p><a href="https://github.com/Luryy">Github</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98f0487605dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kafka - Consumindo dados do Postgres]]></title>
            <link>https://lucas-yuri.medium.com/kafka-consumindo-dados-do-postgres-1f91166c19bf?source=rss-b8ec5e614113------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f91166c19bf</guid>
            <category><![CDATA[debezium]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[postgres]]></category>
            <dc:creator><![CDATA[Lucas Yuri]]></dc:creator>
            <pubDate>Wed, 10 Feb 2021 19:34:20 GMT</pubDate>
            <atom:updated>2021-02-10T19:58:57.371Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/801/0*g7nkAq1IzW8Xzyvo.png" /></figure><p>Fala pessoal!</p><p>Nesse tutorial estarei ensinando como conectar sua aplicação para<strong> escutar</strong> sempre que houver <strong>alguma alteração em seu banco de dados</strong>, recebendo uma <strong>mensagem/notificação</strong>.</p><p>Para auxiliar seu aprendizado, deixei uma aplicação pronta como exemplo. Recomendo que apenas <strong>faça o clone da aplicaçã</strong>o e siga o passo a passo desse tutorial. Link abaixo:</p><p><a href="https://github.com/Luryy/kafka-connect-postgres-implementations">Luryy/kafka-connect-postgres-implementations</a></p><p>Além de nossa aplicação e o banco de dados, precisaremos também de serviços externos para realizar essa integração. Para isso utilizaremos o <strong>debezium</strong>, <strong>kafka</strong> e <strong>kafka connect</strong>.</p><p>O <strong>Debezium </strong>é um serviço para transformar as alterações realizadas no banco de dados em eventos. <a href="https://debezium.io/documentation/reference/index.html">Saiba Mais</a></p><p>O <strong>Kafka </strong>é um serviço para a transmissão de eventos, sendo o serviço que a aplicação se conecta para receber as mensagens. <a href="http://kafka.apache.org/">Saiba Mais</a></p><p>O <strong>Kafka Connect </strong>é um serviço para realizar as configurações e conexão do Kafka com outros serviços (em nosso caso é o Debezium). <a href="https://docs.confluent.io/platform/current/connect/index.html">Saiba Mais</a></p><p>Para criação desses serviços, basta usar o docker-compose presente no respositório disponibilizado. <em>Lembrando que você deverá possuir o </em><a href="https://www.docker.com/"><em>Docker</em></a><em> instalado em sua máquina.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d398c5372f5e495183d7fdb5b0ba62d3/href">https://medium.com/media/d398c5372f5e495183d7fdb5b0ba62d3/href</a></iframe><p>Antes de subir os container, é necessário que você crie o arquivo <strong>.env </strong>baseado no seu .env.example. Você deverá apenas alterar a variável <strong>HOST </strong>inserindo o <strong>IP </strong>sua máquina.</p><p>Após a criação do .env, rode o seguinte comando para inicializar os serviços: (<em>note que o postgres também será inicializado</em>)</p><pre>docker-compose -f docker-compose.yml up -d</pre><p>Com nossos serviços rodando, primeiramente vamos utilizar o postgres. Como será necessário realizar algumas queries em nosso banco, sugiro que utilize o <a href="https://www.electronjs.org/apps/postbird">Postbird</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9gLszS5bDU0WeHIbe8RBmw.png" /><figcaption>Postbird Exemplo — Basta apenas se conectar com o banco de dados e rodar as queries no campo “query”</figcaption></figure><p>Primeiramente vamos alterar a seguinte configuração em nosso banco de dados:<br><em>*Pode utilizar outra forma para alterar a configuração do banco de dados, mas rodar a query abaixo através do postbird já é suficiente</em></p><pre>ALTER SYSTEM SET wal_level TO logical;</pre><p>Aproveitando, já vamos criar a nossa tabela <em>user_info </em>no banco de dados:</p><pre>CREATE TABLE user_info(<br> id integer not null,<br>  name varchar,<br>  alias varchar,<br>  age integer,<br>  active boolean default true,<br>  created_at timestamp not null default now(),<br>  PRIMARY KEY(id)<br>);</pre><p>Para que a alteração de configuração do banco tenha efeito, precisamos <strong>restartar o serviço</strong>:</p><pre>docker-compose -f docker-compose.yml restart</pre><p>Para finalizar as configurações, vamos criar a conexão do<strong> kafka connect.</strong></p><p>Com todos os serviços do docker-compose rodando, você deverá fazer uma requisição do tipo <strong><em>POST</em></strong><em> para a URL: </em><a href="http://localhost:8083/connectors"><strong>http://localhost:8083/connectors</strong></a><strong> </strong>contendo o body abaixo:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36ff3691f8510c09f8a52373a758e116/href">https://medium.com/media/36ff3691f8510c09f8a52373a758e116/href</a></iframe><p>Após a criação, você deverá obter a seguinte resposta:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0itG6KmJ4KSwSMwutZfxng.png" /></figure><p>Com as configurações finalizadas, chegou a hora de <strong>consumir os dados </strong>em nossa aplicação.<br>Vamos então iniciar nossa aplicação:<br>*<em>Lembrando que todos os serviços devem estar rodando</em></p><pre>yarn start</pre><p>Com nossa aplicação em pé, chegou a hora de inserir dados em nossa tabela para recebermos o dados através do kafka:</p><pre>INSERT INTO user_info VALUES (1, &#39;Lucas Yuri&#39;, &#39;luryy&#39;, 20);</pre><p>Após os dados serem inseridos em nossa tabela <em>user_info, </em>no console da nossa aplicação deverá aparecer o seguinte log:</p><pre>{<br>  before: <strong>null</strong>,<br>  after: {<br>    id: 3,<br>    name: &#39;Lucas Yuri&#39;,<br>    alias: &#39;luryy&#39;,<br>    age: 20,<br>    active: true,<br>    created_at: 1612453841643182<br>  },<br>  source: {<br>    version: &#39;1.2.5.Final&#39;,<br>    connector: &#39;postgresql&#39;,<br>    name: &#39;kafka-tutorial&#39;,<br>    ts_ms: 1612453841643,<br>    snapshot: &#39;false&#39;,<br>    db: &#39;postgres&#39;,<br>    schema: &#39;public&#39;,<br>    table: &#39;user_info&#39;,<br>    txId: 490,<br>    lsn: 23478448,<br>    xmin: <strong>null</strong><br>  },<br>  op: &#39;c&#39;,<br>  ts_ms: 1612453842388,<br>  transaction: <strong>null</strong><br>}</pre><p>Com isso finalizamos mais um tutorial. Agora você já tem uma aplicação consumido através do <strong>debezium-kafka</strong> as alterações realizadas em seu<strong> banco de dados postgres</strong>!</p><p>Vale resaltar que esse tutorial ensina o básico para o consumo das mensagens gerados, <strong>cabe a você explorar os detalhes e otimizar a aplicação</strong>!<br>Sugiro que tente consumir esses dados gerados do postgres (SQL) e tentar inserir em um Mongo(NoSQL) — que foi a minha motivação para usar o kafka-connect.</p><p>Caso queira outro artigo contendo os detalhes das configurações dos serviços, deixa aqui nos comentários, e para qualquer dúvida, fico sempre a disposição!</p><p><a href="https://www.linkedin.com/in/lucas-yuri/">Lucas Yuri - Back-end Developer - Node.js - Onyma Digital | LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f91166c19bf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Merging git repositories without lose commits history]]></title>
            <link>https://lucas-yuri.medium.com/merging-git-repositories-without-lose-commits-history-665710a13b43?source=rss-b8ec5e614113------2</link>
            <guid isPermaLink="false">https://medium.com/p/665710a13b43</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[merge-repositories]]></category>
            <category><![CDATA[commit]]></category>
            <dc:creator><![CDATA[Lucas Yuri]]></dc:creator>
            <pubDate>Tue, 01 Dec 2020 21:51:52 GMT</pubDate>
            <atom:updated>2020-12-01T21:51:52.351Z</atom:updated>
            <content:encoded><![CDATA[<p>In this tutorial I’ll show how to merge git separated repositories in a new one without lose it’s commits history</p><p>First you need to create a new repository and start git</p><pre>git init</pre><p>Create a <a href="http://readme.md/">README.md</a> (you should have an initial commit)</p><pre>dir &gt; README.md<br>git add .<br>git commit -m &quot;Create README.md&quot;</pre><p>Add your merge repository as remote</p><pre>git remote add merge_repo &lt;repo URL&gt;<br>git fetch merge_repo</pre><p>Merge your repository | * — allow-unrelated-histories it’s because since 2.9.0, Git doesn’t allow automatic merges with repositories with different histories</p><pre>git merge merge_repo/master --allow-unrelated-histories</pre><p>Create a new folder to your first repository</p><pre>mkdir FirstRepoFolder</pre><p>Now move all Repository files to your folder</p><pre>git mv &lt;files&gt; ./FirstRepoFolder</pre><p>After you move all of your files, you should commit</p><pre>git commit -m &quot;docs: move FirstRepo into a paste&quot;</pre><p>Now you’ve already complete your first merge</p><p>To merge the second repository, let’s reset the remote repository</p><pre>git remote set-url merge_repo &lt;repo URL&gt;<br>git fetch merge_repo</pre><p>And follow the same steps as the first</p><pre>git merge merge_repo/master --allow-unrelated-histories<br>mkdir SecondRepoFolder<br>git mv &lt;files&gt; ./SecondRepoFolder<br>git commit -m &quot;docs: move SeconddRepo into a paste&quot;</pre><p>And that’s all, now you have yours repositories merged without loose it’s commits history</p><p>*As you can see, you could repeat this process as many times as you want with others repositories.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=665710a13b43" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Typegoose — Alterando Schema name e utilização do populate()]]></title>
            <link>https://lucas-yuri.medium.com/typegoose-alterando-schema-name-e-utiliza%C3%A7%C3%A3o-do-populate-540de100da74?source=rss-b8ec5e614113------2</link>
            <guid isPermaLink="false">https://medium.com/p/540de100da74</guid>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[typegoose]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Lucas Yuri]]></dc:creator>
            <pubDate>Mon, 28 Sep 2020 20:47:26 GMT</pubDate>
            <atom:updated>2020-09-28T20:47:26.544Z</atom:updated>
            <content:encoded><![CDATA[<h3>Typegoose — Alterando Schema name e utilização do populate()</h3><p>Fala galera 👋, nesse tutorial irei ensinar como alterar o nome de um Schema, referência-lo e usar o método Populate no Typegoose.</p><p>Considerações: <em>O método Populate tem como intuito “popular” o campo de referência de um Schema com os elementos do Schema referenciado. Ele se assemelha ao </em><strong><em>JOIN </em></strong><em>em banco de dados SQL.</em></p><p>Então vamos lá, primeiramente vamos alterar o nome do schema:</p><p>Abaixo temos o exemplo de um simples schema, que quando criado terá o seguinte nome no banco de dados: <strong>documenttype</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3a3fab273d23c6b52d821dbb34438ce/href">https://medium.com/media/d3a3fab273d23c6b52d821dbb34438ce/href</a></iframe><p>Agora, para alterar seu nome de criação:</p><ul><li>adicionamos o decorator <strong>modelOpitions</strong></li><li>em <strong>customName</strong>, definimos o nome que desejamos.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/523313ea3a110e95e0ff2adee9cd6d28/href">https://medium.com/media/523313ea3a110e95e0ff2adee9cd6d28/href</a></iframe><p>Pronto, agora nosso schema será criado com um nome personalizado.</p><p>Vamos então criar o Schema com a referência para nossa tabela e que em queries futuras será populada:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4f43208dc1f478ff809c080d8b627dde/href">https://medium.com/media/4f43208dc1f478ff809c080d8b627dde/href</a></iframe><p>Usando a propriedade <strong>ref </strong>na definição da propriedade, conseguimos então fazer o relacionamento entre as duas tabelas.</p><p>Com a parte de Schema e referência finalizados, podemos então realizar a query no Document Schema, usando o método populate para que venha a Referência de DocumentType:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b1ee70833624492c9a0d607ca6a27f9/href">https://medium.com/media/5b1ee70833624492c9a0d607ca6a27f9/href</a></iframe><p>Teoricamente, essa query deveria retornar nosso <em>document </em>populado, apenas passando o parâmetro <em>‘type’ </em>(nome do campo que referencia) no método populate.</p><p>Contudo, como alteramos o nome do Schema referenciado, o typegoose não consegue captar isso automaticamente e para isso temos que realizar a query da seguinte maneira:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/421335d6337a77f085b33764f4dc8c4d/href">https://medium.com/media/421335d6337a77f085b33764f4dc8c4d/href</a></iframe><p>Perceba que a alteração necessária é passar como parâmetro na função <em>populate </em>um objeto contendo as informações<em> </em><strong>path</strong><em>: o nome do campo que referencia, e </em><strong><em>model</em></strong><em>: o modelo referenciado.</em></p><p>Essa alteração é necessária, pois caso o parâmetro model não fosse passado, o typegoose iria buscar a tabela <em>documenttype</em> (o nome padrão que nosso Schema seria criado) no banco de dados, mas como esse nome foi alterado, ele não iria encontrar. Passando então o model como parâmetro, ele consegue achar a tabela correta e retornar perfeitamente nossa query.</p><p>Por hoje é só pessoal 👋🏼, comenta aqui embaixo o que você achou e se eu te ajudei de alguma maneira em seu projeto 😉.</p><p>Até a próxima!</p><p>Lucas Yuri — Full Stack Developer</p><p><a href="https://www.linkedin.com/in/lucas-yuri/"><em>LinkedIn</em></a></p><p><a href="https://github.com/Luryy"><em>GitHub</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=540de100da74" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>