title: How to call the function in backend in Node.js & koa2
body: <p>I use Node.js, koa2 and ejs to build a website, and there's a function like following</p>
  
  <p>in app.js</p>
  
  <pre><code>mysqOptlModel.getAllRecords()
  .then(async(result) =&gt; {
     await ctx.render('AllRecordsView', {
         allrecords:result
     })
  })
  </code></pre>
  
  <p>in <code>list.ejs</code> of the frontend</p>
  
  <pre><code>&lt;% allrecords.forEach(function(item, i){%&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;%=item.username%&gt;&lt;/td&gt;
    &lt;td&gt;&lt;%=item.createdtime%&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;%})%&gt;
  </code></pre>
  
  <p><strong>Here are my questions</strong></p>
  
  <ol>
  <li><p>I don't want to show the full username, I just want to show some parts, and some is instead by *</p></li>
  <li><p>The createdtime is timestamp format, and I want to change it to Date format</p></li>
  </ol>
  
  <p><strong>My current solution</strong></p>
  
  <p>I write two JavaScript function in <code>list.ejs</code>, and call them to use.</p>
  
  <p><strong>My expectation</strong></p>
  
  <p>I want to do this in <code>app.js</code>, not in list.ejs</p>
  
  <p>Is there any ideas?</p>