<?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: Pedro Correia</title>
    <description>The latest articles on DEV Community by Pedro Correia (@pvinicius).</description>
    <link>https://dev.to/pvinicius</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%2F759020%2F2537c2b1-83cd-43f4-90aa-6bcaa30e5143.jpeg</url>
      <title>DEV Community: Pedro Correia</title>
      <link>https://dev.to/pvinicius</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pvinicius"/>
    <language>en</language>
    <item>
      <title>I had to create a Guest Mode mechanism in React</title>
      <dc:creator>Pedro Correia</dc:creator>
      <pubDate>Fri, 22 Nov 2024 02:19:47 +0000</pubDate>
      <link>https://dev.to/pvinicius/i-had-to-create-a-guest-mode-mechanism-in-reactjs-4pcb</link>
      <guid>https://dev.to/pvinicius/i-had-to-create-a-guest-mode-mechanism-in-reactjs-4pcb</guid>
      <description>&lt;h2&gt;
  
  
  Introducing
&lt;/h2&gt;

&lt;p&gt;As usual, in all my previous projects it's very common to use some auth provider to do the authentication mechanism, but this case would be different, besides the usual case of using an auth provider, I would create a guest mode mechanism.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Use Case
&lt;/h2&gt;

&lt;p&gt;It's a project where users can manage their project, it's a simple CRUD.&lt;br&gt;
The thing is, if you are a registered user you can save as many projects as you want in the app, however as a guest user the criteria acceptance is a bit different, &lt;strong&gt;&lt;em&gt;as a guest user you can only save 1 project.&lt;/em&gt;&lt;/strong&gt;. Just to let you know, there's a size limit to be saved, but it depends on some variables, like: browser and disk space. &lt;br&gt;
If you want to know this limit, use the method from Storage API &lt;code&gt;navigator.storage.estimate()&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16jn5d51b3ezjlmt07bs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16jn5d51b3ezjlmt07bs.png" alt="Image description" width="315" height="244"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What solution did I apply?
&lt;/h2&gt;

&lt;p&gt;I choose indexedDB to save all guest users data in the browser, and I counted with Dexie(&lt;a href="https://dexie.org/docs/Tutorial/React" rel="noopener noreferrer"&gt;https://dexie.org/docs/Tutorial/React&lt;/a&gt;) to help me.&lt;/p&gt;

&lt;p&gt;As the project creation for the logged in users was done, I already knew all the properties I'd need for the guest users. I'll explain how I solved this challenge step by step.&lt;/p&gt;

&lt;p&gt;Step 1: Installing dexie&lt;br&gt;
yarn&lt;br&gt;
&lt;code&gt;yarn add dexie&lt;br&gt;
yarn add dexie-react-hooks&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;npm&lt;br&gt;
&lt;code&gt;npm install dexie&lt;br&gt;
npm install dexie-react-hooks&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Step 2:&lt;/em&gt; I've created an interface with all needed properties to be used on Project Creation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7jygtfvlp49lhg2bt31f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7jygtfvlp49lhg2bt31f.png" alt="IProject.ts" width="756" height="670"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Step 3:&lt;/em&gt; I created a hook to initialise the Dexie context, which contains the database and schema creation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F00foa5pzjkp7u1pt7zlr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F00foa5pzjkp7u1pt7zlr.png" alt="db.ts" width="800" height="415"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Step 4:&lt;/em&gt; Let's create a form to create our project, including the addProject function to perform the operation through the db context.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq9208m4mkrd969j6nm5l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq9208m4mkrd969j6nm5l.png" alt="ProjectForm.tsx" width="800" height="1155"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Step 5:&lt;/em&gt; Let's create a List component to show all projects that have been created and perform the useLiveQuery function through the db context.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6yubhllflnon23i2blj3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6yubhllflnon23i2blj3.png" alt="ProjectList.tsx" width="800" height="595"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Step 6:&lt;/em&gt; And finally, after adding a project, you can see in the application tab on browser settings, indexedDB and ProjectDB, all projects that is listed, for sure you can close and open the browser all data is persisted until you clear the DB.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk4kv8p3fmzi48o79di3p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk4kv8p3fmzi48o79di3p.png" alt="Example" width="800" height="351"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope you can use it to manage your guest users as well, and if you want to play with this demo, follow the codesandbox bellow.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codesandbox.io/p/sandbox/react-typescript-forked-pfpdz8?workspaceId=51e2f20f-c72d-466e-8e65-35cf50be13d0" rel="noopener noreferrer"&gt;https://codesandbox.io/p/sandbox/react-typescript-forked-pfpdz8?workspaceId=51e2f20f-c72d-466e-8e65-35cf50be13d0&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>react</category>
      <category>learning</category>
    </item>
    <item>
      <title>How did I automate the execution of database scripts on Azure Pipelines?</title>
      <dc:creator>Pedro Correia</dc:creator>
      <pubDate>Tue, 16 Jan 2024 23:43:40 +0000</pubDate>
      <link>https://dev.to/pvinicius/how-did-i-automate-the-execution-of-database-scripts-on-azure-pipelines-454e</link>
      <guid>https://dev.to/pvinicius/how-did-i-automate-the-execution-of-database-scripts-on-azure-pipelines-454e</guid>
      <description>&lt;h2&gt;
  
  
  Indroducing
&lt;/h2&gt;

&lt;p&gt;As the title suggests, this post discusses the time when I needed to create a pipeline to automatically deploy all changes to the database schema, including ADD/ALTER TABLES, ADD/ALTER COLUMNS, PROCEDURES, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Use Case
&lt;/h2&gt;

&lt;p&gt;The use case involves a project built using Azure SQL Server with Dapper and .NET 7, where each client has its instance of the database. Within the .NET project, there's a Database project responsible for versioning all the database changes, and that part is fine. However, the issue arises when deploying a new schema change as it had to be done manually using Scheme Compare (a function provided by Database projects in Visual Studio IDE). This manual process became time-consuming, especially as the number of clients increased, requiring more scheme comparisons and manual control. This is the reason for automating these processes. How do I automate it?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Database_Project&lt;/em&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F667c7rtbcs4mtfpk0lx8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F667c7rtbcs4mtfpk0lx8.png" alt="Image description" width="432" height="275"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  What solution I apply?
&lt;/h2&gt;

&lt;p&gt;To begin with, I created a new Azure repository specifically to store the Database project, allowing me to subsequently create a dedicated pipeline for it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk4y0jhn89ee1xdupylrb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk4y0jhn89ee1xdupylrb.png" alt="Image description" width="430" height="140"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I created a YML pipeline with the following instructions: it builds the database project and saves the artifact in the drop folder. This artifact is then utilized for proper deployment on Azure SQL Database.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;trigger:
- main
- stage
- development

pool:
  vmImage: windows-latest

stages:

- stage: 'ContinuousIntegration'
  displayName: 'Continuous Integration'
  jobs:
    - job: BuildPublishArtifacts
      displayName: 'Building &amp;amp; Publish Solution Artifacts'
      steps:
        - task: MSBuild@1
          displayName: 'Building Solution'
          inputs:
            solution: '**/*.sln'
            clean: true
            configuration: 'Release'
            platform: 'Any CPU'

        - task: CopyFiles@1
          displayName: 'Moving Database Artifacts to Drop folder'
          inputs:
            SourceFolder: '$(Agent.BuildDirectory)\s\Database\bin\Release'
            Contents: '**'
            TargetFolder: '$(Build.ArtifactStagingDirectory)\DBArtifact'

        - task: PublishBuildArtifacts@1
          displayName: 'Publishing Solution Artifact'
          inputs:
            PathtoPublish: '$(Build.ArtifactStagingDirectory)'
            ArtifactName: 'drop'
            publishLocation: Container
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, the last step I had to take was to create a release, set up the artifact built by the pipeline, and create a task to deploy a DACPAC.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjiw8zfl0o2b06kqoeeyx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjiw8zfl0o2b06kqoeeyx.png" alt="Image description" width="652" height="261"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, this isn't a guide; instead, I'm sharing a use case that I encountered during my work and explaining why I chose to automate this process.&lt;/p&gt;

&lt;p&gt;Have you ever automate that?&lt;/p&gt;

</description>
      <category>azure</category>
      <category>devops</category>
      <category>programming</category>
      <category>dotnet</category>
    </item>
    <item>
      <title>First of all let me introduce myself.</title>
      <dc:creator>Pedro Correia</dc:creator>
      <pubDate>Wed, 17 Aug 2022 16:34:00 +0000</pubDate>
      <link>https://dev.to/pvinicius/first-of-all-let-me-introduce-myself-193l</link>
      <guid>https://dev.to/pvinicius/first-of-all-let-me-introduce-myself-193l</guid>
      <description>&lt;p&gt;Hello everyone, I'm Pedro Correia I'm a Software Engineer at ABB, I have 6 years of experience and all the time always working with Microsoft Technologies, like .net MVC, .net core, azure DevOps, but I have some pieces of knowledge with angular and reactjs. Currently, I've been working with a Poland team, I had never ever worked with a foreign team, and they are a great team, but I'm working from Brazil. In my free time, I like to play video games, play soccer(I support Palmeiras), and sometimes play skateboarding, I really like to go to the bar, luckily where I live there are many options for bars and parties. If you already visited São Paulo Capital, you know what I'm saying. The purpose of this blog is to practice and improve my English, and to write about my studies, so the main posts of this blog will be tech, but sometimes I can write about my passions as well.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc6z4y8duigsuitqjhq3w.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc6z4y8duigsuitqjhq3w.jpg" alt="me" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;See you later.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>introducemyself</category>
    </item>
  </channel>
</rss>
