<?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: Yasunori Tanaka</title>
    <description>The latest articles on DEV Community by Yasunori Tanaka (@yasunoritanaka).</description>
    <link>https://dev.to/yasunoritanaka</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%2F143084%2Fce11b116-8985-4315-8386-04405373a35a.jpeg</url>
      <title>DEV Community: Yasunori Tanaka</title>
      <link>https://dev.to/yasunoritanaka</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yasunoritanaka"/>
    <language>en</language>
    <item>
      <title>[WIP] Quasar</title>
      <dc:creator>Yasunori Tanaka</dc:creator>
      <pubDate>Thu, 05 Aug 2021 08:48:44 +0000</pubDate>
      <link>https://dev.to/yasunoritanaka/wip-quasar-302i</link>
      <guid>https://dev.to/yasunoritanaka/wip-quasar-302i</guid>
      <description>&lt;h1&gt;
  
  
  Quasar
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Style
&lt;/h2&gt;

&lt;p&gt;Quasar component and css style is almost same of Vuetify. If you are familiar with Vuetify, Quasar is easy to understand.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;q-layout&lt;/span&gt; &lt;span class="na"&gt;view=&lt;/span&gt;&lt;span class="s"&gt;"hHh lpR fFf"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    // same of Vuetify's v-app-bar
    &lt;span class="nt"&gt;&amp;lt;q-header&amp;gt;&lt;/span&gt;...

    // same of Vutify's v-navigation-drawer
    &lt;span class="nt"&gt;&amp;lt;q-drawer&amp;gt;&lt;/span&gt;...

    // specify color with class
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;text-blue&lt;/span&gt; &lt;span class="na"&gt;bg-primary&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Theme builder
&lt;/h2&gt;

&lt;p&gt;You can create your project's theme with the theme builder.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0y3Ggswz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xu008vqzww324q1pyv0r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0y3Ggswz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xu008vqzww324q1pyv0r.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After build, you will get your style. Below is the example in SASS.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sass"&gt;&lt;code&gt;&lt;span class="nv"&gt;$primary&lt;/span&gt;   &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#027BE3&lt;/span&gt;
&lt;span class="nv"&gt;$secondary&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#26A69A&lt;/span&gt;
&lt;span class="nv"&gt;$accent&lt;/span&gt;    &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#9C27B0&lt;/span&gt;

&lt;span class="nv"&gt;$dark&lt;/span&gt;      &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#1D1D1D&lt;/span&gt;

&lt;span class="nv"&gt;$positive&lt;/span&gt;  &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#21BA45&lt;/span&gt;
&lt;span class="nv"&gt;$negative&lt;/span&gt;  &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#C10015&lt;/span&gt;
&lt;span class="nv"&gt;$info&lt;/span&gt;      &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#31CCEC&lt;/span&gt;
&lt;span class="nv"&gt;$warning&lt;/span&gt;   &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#F2C037&lt;/span&gt;

&lt;span class="nv"&gt;$primary&lt;/span&gt;   &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#f39800&lt;/span&gt;
&lt;span class="nv"&gt;$secondary&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#f19c00&lt;/span&gt;
&lt;span class="nv"&gt;$accent&lt;/span&gt;    &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#f17b38&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set your them in Quasar option.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;quasar-user-option.js&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;brand&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;primary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#f39800&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;secondary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#f19c38&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;accent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#f17b38&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

      &lt;span class="na"&gt;dark&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#1d1d1d&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

      &lt;span class="na"&gt;positive&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#55e700&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;negative&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#e70055&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;info&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#0055e7&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;warning&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#e7d400&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt;
  &lt;span class="na"&gt;lang&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;lang&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use Quasar with the option in Vue.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;main.ts&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;quasarUserOptions&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./quasar-user-options&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createApp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Quasar&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;quasarUserOptions&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Layout builder
&lt;/h2&gt;

&lt;p&gt;Quasar provides us common layout patterns. At first before/after we can generate Vue template with GUI.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D-BfsABV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xgtb89ha9b1dzzf8ukg6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D-BfsABV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xgtb89ha9b1dzzf8ukg6.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The generated template is compatible with Vue Router. You just copy and paste it into your root Vue component.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--godV4UNJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/45wl0wm3va1sxaglraug.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--godV4UNJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/45wl0wm3va1sxaglraug.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  PrimeVue
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Style
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;template&amp;gt;
  &amp;lt;div class=&amp;gt;
  &amp;lt;div&amp;gt;
    &amp;lt;Menubar :model="items"&amp;gt;
      &amp;lt;template #start&amp;gt;
        asa
        &amp;lt;i style="color: var(--text-color)" class="pi pi-apple"&amp;gt;&amp;lt;/i&amp;gt;
      &amp;lt;/template&amp;gt;
    &amp;lt;/Menubar&amp;gt;
    &amp;lt;router-view&amp;gt;&amp;lt;/router-view&amp;gt;
  &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Theme builder
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Layout builder
&lt;/h2&gt;

&lt;p&gt;we should &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Creating business logic on Amplify</title>
      <dc:creator>Yasunori Tanaka</dc:creator>
      <pubDate>Wed, 09 Dec 2020 07:53:07 +0000</pubDate>
      <link>https://dev.to/yasunoritanaka/creating-business-logic-on-amplify-5af</link>
      <guid>https://dev.to/yasunoritanaka/creating-business-logic-on-amplify-5af</guid>
      <description>&lt;p&gt;As described in &lt;a href="https://aws.amazon.com/blogs/mobile/appsync-microservices/" rel="noopener noreferrer"&gt;this document&lt;/a&gt;, GraphQL on AppSync can connect many data sources as business logic. For example, API Gateway, another AppSync, and Fargate via HTTP and lambda function.&lt;/p&gt;

&lt;p&gt;I think, for a small project, the lambda function as a data source is useful for writing business logic.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6vn5zcdyckta7x34clvn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6vn5zcdyckta7x34clvn.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have two approaches to get data. A lambda function gets data from DynamoDB and GraphQL.&lt;/p&gt;

&lt;h1&gt;
  
  
  Create a lambda function
&lt;/h1&gt;

&lt;p&gt;See also, &lt;a href="https://docs.amplify.aws/guides/functions/dynamodb-from-js-lambda/q/platform/js" rel="noopener noreferrer"&gt;https://docs.amplify.aws/guides/functions/dynamodb-from-js-lambda/q/platform/js&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ amplify add function
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Amplify function needs permission to read/write to DynamoDB and GraphQL&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ amplify update function

? Do you want to update the Lambda function permissions to access other resources in this project? Yes
? Select the category api, storage
Api category has a resource called amplifynuxt
? Select the operations you want to permit for amplifynuxt create, read, update, delete
Storage category has a resource called &amp;lt;Your DynamoDB table&amp;gt;:@model(appsync)
? Select the operations you want to permit for &amp;lt;Your DynamoDB table&amp;gt;:@model(appsync) create, read, update, delete
...

You can access the following resource attributes as environment variables from your Lambda function
        API_&amp;lt;Your API name&amp;gt;_GRAPHQLAPIENDPOINTOUTPUT
        API_&amp;lt;Your API name&amp;gt;_GRAPHQLAPIIDOUTPUT
        API_&amp;lt;Your API name&amp;gt;_GRAPHQLAPIKEYOUTPUT
        API_&amp;lt;Your API name&amp;gt;_PROPERTYTABLE_ARN
        API_&amp;lt;Your API name&amp;gt;_PROPERTYTABLE_NAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add a query in &lt;em&gt;schema.graphql&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;schema.graphql&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type Query {
  getData(msg: String): String @function(name: "&amp;lt;your lambda function name&amp;gt;-${env}")
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Gets data from DynamoDB
&lt;/h2&gt;

&lt;p&gt;In your &lt;em&gt;index.js&lt;/em&gt; in &lt;em&gt;amplify/backend/function/&amp;lt;your lambda function name&amp;gt;/src&lt;/em&gt;, change code like blow.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const AWS = require('aws-sdk');
const docClient = new AWS.DynamoDB.DocumentClient();

const params = {
  TableName : 'your-table-name',
  Item: {
     id: '12345',
  }
}

async function getItem(){
  try {
    await docClient.put(params).promise();
  } catch (err) {
    return err;
  }
}

exports.handler = async (event) =&amp;gt; {
  try {
    await getItem()
    return { body: 'Successfully created item!' }
  } catch (err) {
    return { error: err }
  }
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Push code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ amplify push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Test the function.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fn0sub8hjcf24h5xtz3sy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fn0sub8hjcf24h5xtz3sy.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  gets data from GraphQL
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npm install axios, graphql-tag, graphql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update the &lt;em&gt;index.js&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* Amplify Params - DO NOT EDIT
    API_&amp;lt;Your API name&amp;gt;_GRAPHQLAPIENDPOINTOUTPUT
    API_&amp;lt;Your API name&amp;gt;_GRAPHQLAPIIDOUTPUT
    API_&amp;lt;Your API name&amp;gt;_GRAPHQLAPIKEYOUTPUT
    API_&amp;lt;Your API name&amp;gt;_PROPERTYTABLE_ARN
    API_&amp;lt;Your API name&amp;gt;_PROPERTYTABLE_NAME
    ENV
    REGION
Amplify Params - DO NOT EDIT */
const axios = require('axios');
const gql = require('graphql-tag');
const graphql = require('graphql');
const { print } = graphql;

const listPropertys = gql`
  query listPropertys {
    listPropertys {
      items {
        id
        name
      }
    }
  }
`

exports.handler = async (event) =&amp;gt; {
  try {
    const graphqlData = await axios({
      url: process.env.API_&amp;lt;Your API name&amp;gt;_GRAPHQLAPIENDPOINTOUTPUT,
      method: 'post',
      headers: {
        'x-api-key': process.env.API_&amp;lt;Your API name&amp;gt;_GRAPHQLAPIKEYOUTPUT
      },
      data: {
        query: print(listPropertys),
      }
    });
    const body = {
        graphqlData: graphqlData.data.data.listPropertys
    }
    return {
        statusCode: 200,
        body: JSON.stringify(body),
        headers: {
            "Access-Control-Allow-Origin": "*",
        }
    }
  } catch (err) {
    console.log('error posting to appsync: ', err);
  } 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Push code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ amplify push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Test the function.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F1whwl2oc1h8rwi4rkmel.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F1whwl2oc1h8rwi4rkmel.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>amplify</category>
      <category>node</category>
    </item>
    <item>
      <title>Pass parent's async data  to child component in NuxtJS</title>
      <dc:creator>Yasunori Tanaka</dc:creator>
      <pubDate>Thu, 27 Aug 2020 02:07:41 +0000</pubDate>
      <link>https://dev.to/yasunoritanaka/pass-parent-s-async-data-to-child-component-in-nuxtjs-1bbo</link>
      <guid>https://dev.to/yasunoritanaka/pass-parent-s-async-data-to-child-component-in-nuxtjs-1bbo</guid>
      <description>&lt;p&gt;One solution that passes data to a child component as props and gets another async data with the props.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;parent component&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;template&amp;gt;
  &amp;lt;Selector :user-id="userId"/&amp;gt;
&amp;lt;/template&amp;gt;

&amp;lt;script&amp;gt;
import Vue from "vue";
import Selector from "~/components/Selector.vue";

export default Vue.extend({
  components: { Selector },

  data() {
    return {
      userId: undefined
    };
  },

  async fetch() {
    this.userId = await this.$asios.$get("http://example.com");
  }
});
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The parent component passes &lt;code&gt;userId&lt;/code&gt; as props.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;child component&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;template&amp;gt;
  &amp;lt;p v-if="user"&amp;gt;{{ user.name }}&amp;lt;/p&amp;gt;
&amp;lt;/template&amp;gt;

&amp;lt;script&amp;gt;
import Vue from "vue";

export default Vue.extend({
  props: {
    userId: {
      type: String,
      required: true
    }
  },

  data() {
    return {
      user: undefined
    };
  },

  watch: {
    userId() {
      this.getUser();
    }
  },

  methods: {
    async getUser() {
      if (!this.userId) {
        return;
      }

      this.user = await this.$asios.$get("http://example.com/get_user");
    }
  }
});
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After the child component get a &lt;code&gt;userId&lt;/code&gt; with &lt;code&gt;watch()&lt;/code&gt;, it requests an async user data.&lt;/p&gt;

</description>
      <category>nuxt</category>
      <category>vue</category>
    </item>
    <item>
      <title>Look into foreign key constraint error in MySQL</title>
      <dc:creator>Yasunori Tanaka</dc:creator>
      <pubDate>Wed, 05 Aug 2020 08:31:39 +0000</pubDate>
      <link>https://dev.to/yasunoritanaka/look-into-foreign-key-constraint-error-in-mysql-531j</link>
      <guid>https://dev.to/yasunoritanaka/look-into-foreign-key-constraint-error-in-mysql-531j</guid>
      <description>&lt;p&gt;Sometimes we encounter the error that we cannot insert/update/delete records by foreign key constraint error. &lt;/p&gt;

&lt;p&gt;The error message like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[23000][1452] Cannot add or update a child row: a foreign key constraint fails
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;But this message may not help us to solve the problem because it doesn't have the detail.&lt;/p&gt;

&lt;p&gt;So we can see the detail with the below query.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;mysql&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;show&lt;/span&gt; &lt;span class="n"&gt;engine&lt;/span&gt; &lt;span class="n"&gt;innodb&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Then we can get the detail in "LATEST FOREIGN KEY ERROR" section.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;------------------------
LATEST FOREIGN KEY ERROR
------------------------
2020-08-05 07:37:15 0x7fe488261700 Transaction:
TRANSACTION 306127, ACTIVE 0 sec updating or deleting
mysql tables in use 1, locked 1
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>mysql</category>
    </item>
    <item>
      <title>Prevent updating query updates all records in GORM</title>
      <dc:creator>Yasunori Tanaka</dc:creator>
      <pubDate>Mon, 03 Aug 2020 11:57:26 +0000</pubDate>
      <link>https://dev.to/yasunoritanaka/prevent-updating-query-updates-all-records-in-gorm-ojj</link>
      <guid>https://dev.to/yasunoritanaka/prevent-updating-query-updates-all-records-in-gorm-ojj</guid>
      <description>&lt;p&gt;Finally, I found that prevent updating all records when I forget with a primary ID in &lt;a href="http://gorm.io/"&gt;GORM&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Sometimes, we forget primary ID for updating a record in a query. This query will occur the problem that all records in the table will be updated because the query does not specify a primary ID.&lt;/p&gt;

&lt;p&gt;A query below will update one record with a company ID.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;gorm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DB&lt;/span&gt;
&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;gorm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"mysql"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;company&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;Company&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;gorm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;companyID&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
   &lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;  &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;company&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;company&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="o"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This query works well wholly.&lt;/p&gt;

&lt;p&gt;In contrast, the blow query without a primary ID will update all records.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;gorm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DB&lt;/span&gt;
&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;gorm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"mysql"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;company&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;Company&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;  &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;company&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;company&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="o"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If this code is deployed to production service with no test, I don't want to imagine that it will do to our database.&lt;/p&gt;

&lt;p&gt;So we can prevent this behavior with &lt;a href="https://godoc.org/github.com/jinzhu/gorm#DB.BlockGlobalUpdate"&gt;func (*DB) BlockGlobalUpdate&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;gorm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DB&lt;/span&gt;
&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;gorm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"mysql"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BlockGlobalUpdate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Again, the same query with not primary ID.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;company&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;Company&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;  &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;company&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;company&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If we forget primary ID like that, we will get an error from GORM like below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2020-08-03T07:45:14.011Z  ERROR  logger/logger.go:58  missing WHERE clause while updating
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;BlockGlobalUpdate()&lt;/code&gt; can prevent updating all records in a table.&lt;/p&gt;

&lt;p&gt;Wrapping up, we should use &lt;code&gt;BlockGlobalUpdate()&lt;/code&gt; when we create a gorm DB instance. Otherwise, someday your query could destroy your user's data entirely.&lt;/p&gt;

</description>
      <category>go</category>
      <category>gorm</category>
    </item>
    <item>
      <title>Using Vuetify v-data-table's interface</title>
      <dc:creator>Yasunori Tanaka</dc:creator>
      <pubDate>Tue, 28 Jul 2020 11:05:46 +0000</pubDate>
      <link>https://dev.to/yasunoritanaka/using-vuetify-v-data-table-s-interface-1h5d</link>
      <guid>https://dev.to/yasunoritanaka/using-vuetify-v-data-table-s-interface-1h5d</guid>
      <description>&lt;p&gt;In .vue file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;v-data-table&lt;/span&gt; &lt;span class="na"&gt;:headers=&lt;/span&gt;&lt;span class="s"&gt;"header"&lt;/span&gt; &lt;span class="na"&gt;:options.sync=&lt;/span&gt;&lt;span class="s"&gt;"options"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; ... &lt;span class="nt"&gt;&amp;lt;/v-data-table&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"ts"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;DataOptions&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;DataTableHeader&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vuetify/types&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;DataType&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;DataOptions&lt;/span&gt;
  &lt;span class="nx"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;DataTableHeader&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;Vue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="nx"&gt;DataType&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
    &lt;span class="nl"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can import interfaces from &lt;code&gt;vuetify/types&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>vue</category>
      <category>vuetify</category>
    </item>
    <item>
      <title>Derive type info from a function</title>
      <dc:creator>Yasunori Tanaka</dc:creator>
      <pubDate>Fri, 17 Jul 2020 09:24:34 +0000</pubDate>
      <link>https://dev.to/yasunoritanaka/derive-type-info-from-function-2161</link>
      <guid>https://dev.to/yasunoritanaka/derive-type-info-from-function-2161</guid>
      <description>&lt;p&gt;We can derive type from a function like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;createPerson&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Yasunori&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Tanaka&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ReturnType&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;createPerson&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And then, use that as &lt;code&gt;Person&lt;/code&gt; type.&lt;/p&gt;

</description>
      <category>typescript</category>
    </item>
    <item>
      <title>The things I noticed in mysterious  project</title>
      <dc:creator>Yasunori Tanaka</dc:creator>
      <pubDate>Thu, 02 Jul 2020 06:23:36 +0000</pubDate>
      <link>https://dev.to/yasunoritanaka/the-things-i-noticed-in-mysterious-project-59np</link>
      <guid>https://dev.to/yasunoritanaka/the-things-i-noticed-in-mysterious-project-59np</guid>
      <description>&lt;h1&gt;
  
  
  Tech
&lt;/h1&gt;

&lt;h2&gt;
  
  
  DB design
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Don't use binary format tool like MySQL Workbench
&lt;/h3&gt;

&lt;p&gt;It's not easy to share a binary file in a team or VCS.&lt;/p&gt;

&lt;h3&gt;
  
  
  Design tables incrementally
&lt;/h3&gt;

&lt;p&gt;Create only the tables that we can know so far. Do not spend time to create entire system tables by estimating the future of the tables. But we should make a sequence diagram of our business at the beginning.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use plural or singular table name for
&lt;/h3&gt;

&lt;p&gt;Plural or singular is not essential. But we should decide which one we use at first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture design
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Don't use an architecture that is over-engineering
&lt;/h3&gt;

&lt;p&gt;We should not use a big architecture like &lt;a href="https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html"&gt;the Clean Architecture&lt;/a&gt; at the beginning. That is just wasting your team's time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Protocol Buffers
&lt;/h3&gt;

&lt;p&gt;We used Protocol Buffers initially, but I think It was over-engineering because we just created a web service that doesn't have special tech. It was enough to use JSON format for communicating between and front-end and back-end.&lt;/p&gt;

&lt;h2&gt;
  
  
  CI and CD
&lt;/h2&gt;

&lt;p&gt;We should prepare an app for checking an overview of it by business members at the first beginning. To reduce uncertainty.&lt;br&gt;
Updating prototyping and web pages.&lt;/p&gt;

&lt;h2&gt;
  
  
  Remote work
&lt;/h2&gt;

&lt;p&gt;Our all team members worked from home and used Zoom and Discord. We use Zoom for only video and Discord for only voice chat. There are great communication tools so far. We feel as if we work at an office together. We don't have any walls between us.&lt;/p&gt;

&lt;h2&gt;
  
  
  research what tech we use
&lt;/h2&gt;

&lt;h2&gt;
  
  
  update our workflow and diagram constantly
&lt;/h2&gt;

&lt;p&gt;Use a sequence diagram on the web, not a local file. It's easy to collaborate.&lt;br&gt;
paper prototyping -&amp;gt; write detail in Figma&lt;/p&gt;

&lt;h3&gt;
  
  
  model
&lt;/h3&gt;

&lt;p&gt;Create a specific model for requesting and receiving data, not use entity.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a prototype view
&lt;/h3&gt;

&lt;p&gt;Share your app's prototype and discuss it with your team. Prototyping should not be costly to create and share.&lt;/p&gt;

&lt;h3&gt;
  
  
  Updating prototype for accuracy
&lt;/h3&gt;

&lt;h1&gt;
  
  
  Project management
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Set a final goal and deadline and make a plan to get there in time. Use the milestone in GitHub to make small goals.
&lt;/h2&gt;

&lt;p&gt;Iterate this&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;create specs&lt;/li&gt;
&lt;li&gt;data structure&lt;/li&gt;
&lt;li&gt;create app&lt;/li&gt;
&lt;li&gt;launch&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Stakeholders can check this app&lt;/p&gt;

&lt;h3&gt;
  
  
  create issues by the members want/suggestion
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Use the Milestone and Project in GitHub.
&lt;/h3&gt;

&lt;p&gt;We should not put pressure too much on members.&lt;br&gt;
Don't do use complex project management schemes and tools like the Scrum in a small team.&lt;/p&gt;

&lt;h3&gt;
  
  
  we should share our goal
&lt;/h3&gt;

&lt;h1&gt;
  
  
  Team
&lt;/h1&gt;

&lt;h3&gt;
  
  
  communication
&lt;/h3&gt;

&lt;p&gt;We should have an environment that makes us easy to communicate each other anytime.&lt;/p&gt;

&lt;h3&gt;
  
  
  respect our team members
&lt;/h3&gt;

</description>
    </item>
    <item>
      <title>[From May 28 to June 3] The things I knew and thought last week</title>
      <dc:creator>Yasunori Tanaka</dc:creator>
      <pubDate>Thu, 04 Jun 2020 06:33:47 +0000</pubDate>
      <link>https://dev.to/yasunoritanaka/from-may-28-to-june-3-the-things-i-knew-and-thought-last-week-1gli</link>
      <guid>https://dev.to/yasunoritanaka/from-may-28-to-june-3-the-things-i-knew-and-thought-last-week-1gli</guid>
      <description>&lt;p&gt;[Nuxt] set/get cookie in SSR&lt;br&gt;
&lt;a href="https://github.com/nuxt/nuxt.js/issues/2215"&gt;https://github.com/nuxt/nuxt.js/issues/2215&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another way&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Cookies from 'js-cookie'
https://github.com/js-cookie/js-cookie
Cookies.set('company.id', companyId, { expires: 7 })
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I created a cookie util that gets cookie by key and parse&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export const getCookie = (cookie: string, key: string): string | undefined =&amp;gt; {
  let item = cookie.split(' ').find((v) =&amp;gt; v.includes(key))
  if (item) {
    // remove semi colon "job.id=32;"
    if (item.includes(';')) {
      item = item.slice(0, -1)
    }
    // "job.id=32"
    const kv = item.split('=')
    item = kv[1]
  }

  return item
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
    </item>
    <item>
      <title>[From May 21 to May 27] The things I knew and thought last week</title>
      <dc:creator>Yasunori Tanaka</dc:creator>
      <pubDate>Thu, 28 May 2020 04:01:44 +0000</pubDate>
      <link>https://dev.to/yasunoritanaka/from-may-21-to-may-27-the-things-i-knew-and-thought-last-week-2921</link>
      <guid>https://dev.to/yasunoritanaka/from-may-21-to-may-27-the-things-i-knew-and-thought-last-week-2921</guid>
      <description>&lt;h1&gt;
  
  
  [vuetify] breadcrumb generator
&lt;/h1&gt;

&lt;p&gt;I want to generate Vuetify's breadcrumb automatically by URL.&lt;/p&gt;

&lt;p&gt;Let's say it the URL is &lt;em&gt;/home/company/list&lt;/em&gt;. The generator makes breadcrumbs like the below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
  {
    title: 'HOME',
    url: '/home',
  },
  {
    title: 'HOME / Companies',
    url: '/home/company/list',
  },
]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h1&gt;
  
  
  [vue] create form initializer
&lt;/h1&gt;

&lt;p&gt;Almost case, I will create an initial data with an interface using TypeScript like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Data&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;
  &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;Vue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="nx"&gt;Data&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;But if the Data interface definition gets much more, I have to fill in all initial value for the Data because the TypeScript compiler cannot build it.&lt;/p&gt;

&lt;p&gt;So I want to generate initial values from a Data interface. Below is an example. &lt;code&gt;generator&lt;/code&gt; function makes initial values from the interface.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;initalValues&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;generator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// initialValues&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h1&gt;
  
  
  [js] module bundler
&lt;/h1&gt;

&lt;p&gt;I'm looking into how module bundler works.&lt;/p&gt;

</description>
      <category>frontend</category>
    </item>
    <item>
      <title>[From May 14 to May 20] The things I knew and thought last week</title>
      <dc:creator>Yasunori Tanaka</dc:creator>
      <pubDate>Thu, 21 May 2020 03:34:22 +0000</pubDate>
      <link>https://dev.to/yasunoritanaka/from-may-14-to-may-20-the-things-i-knew-and-thought-last-week-84e</link>
      <guid>https://dev.to/yasunoritanaka/from-may-14-to-may-20-the-things-i-knew-and-thought-last-week-84e</guid>
      <description>&lt;p&gt;[RDB] The upper size of table name is 64 characters in MySQL 5.6 and 8.0&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.mysql.com/doc/refman/5.6/en/identifier-length.html"&gt;https://dev.mysql.com/doc/refman/5.6/en/identifier-length.html&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.mysql.com/doc/refman/8.0/en/identifier-length.html"&gt;https://dev.mysql.com/doc/refman/8.0/en/identifier-length.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;[GORM] belonging to &lt;/p&gt;

&lt;p&gt;Foreign key&lt;/p&gt;

&lt;p&gt;[GORM] Polymorphism association&lt;/p&gt;

&lt;p&gt;[vue] syntax error when I use "esnext" in tsconfig.json&lt;/p&gt;

&lt;p&gt;"es2018"&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export interface Item {
  name?: string
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I used this interface &lt;code&gt;const name = item?.name&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;[vue]&lt;/p&gt;

&lt;p&gt;$ref&lt;/p&gt;

&lt;p&gt;[GORM] use where&lt;/p&gt;

&lt;p&gt;[GORM] auto preload&lt;/p&gt;

&lt;p&gt;[vue] watch object data&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;watch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;item.name&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// do something&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>frontend</category>
      <category>backend</category>
    </item>
    <item>
      <title>[From May 7 to May 13] The things I knew and thought last week</title>
      <dc:creator>Yasunori Tanaka</dc:creator>
      <pubDate>Thu, 14 May 2020 07:13:42 +0000</pubDate>
      <link>https://dev.to/yasunoritanaka/from-may-7-to-may-13-the-things-i-knew-and-thought-last-week-5dgm</link>
      <guid>https://dev.to/yasunoritanaka/from-may-7-to-may-13-the-things-i-knew-and-thought-last-week-5dgm</guid>
      <description>&lt;p&gt;[Vue] Adding component dynamically&lt;br&gt;
&lt;a href="https://vuejs.org/v2/guide/components.html#Dynamic-Components"&gt;https://vuejs.org/v2/guide/components.html#Dynamic-Components&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;parent.vue&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;component&lt;/span&gt;
   &lt;span class="na"&gt;v-for=&lt;/span&gt;&lt;span class="s"&gt;"(item, index) in items"&lt;/span&gt;
   &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="na"&gt;appendAmount=&lt;/span&gt;&lt;span class="s"&gt;"appendAmount(index, $event)"&lt;/span&gt;
   &lt;span class="na"&gt;v-bind:amount=&lt;/span&gt;&lt;span class="s"&gt;"device.amount"&lt;/span&gt;
   &lt;span class="na"&gt;v-bind:is=&lt;/span&gt;&lt;span class="s"&gt;"'Selector'"&lt;/span&gt;
   &lt;span class="na"&gt;:key=&lt;/span&gt;&lt;span class="s"&gt;"device.deviceId"&lt;/span&gt;
 &lt;span class="nt"&gt;&amp;gt;&amp;lt;/component&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;Vue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
&lt;span class="nx"&gt;methods&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://codesandbox.io/s/dynamic-components-762se"&gt;https://codesandbox.io/s/dynamic-components-762se&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;[Vue] How to use HOC in an event&lt;/p&gt;

&lt;p&gt;[Vue] .sync modifier&lt;/p&gt;

&lt;p&gt;[Vue] $data in IntelliJ IDEA&lt;/p&gt;

&lt;p&gt;&lt;code&gt;this.$data.form&lt;/code&gt; &lt;code&gt;this.form&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;[Vue] Getting parent and chile component's parameter in the same function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;$emit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;...&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;$event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;@...&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;$event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;[Vue] @click.prevent&lt;/p&gt;

&lt;p&gt;[Protocol Buffers] Cyclic import&lt;/p&gt;

&lt;p&gt;[GORM] Using gorm.Model.ID for replacing on Association Replace&lt;/p&gt;

</description>
      <category>vue</category>
      <category>go</category>
      <category>protocolbuffers</category>
    </item>
  </channel>
</rss>
