<?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>Forem: mgcunado</title>
    <description>The latest articles on Forem by mgcunado (@mgcunado).</description>
    <link>https://forem.com/mgcunado</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%2F836613%2F7a330afb-0b78-4774-ae97-83f65ad35072.png</url>
      <title>Forem: mgcunado</title>
      <link>https://forem.com/mgcunado</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mgcunado"/>
    <language>en</language>
    <item>
      <title>Raw query in sequilize model</title>
      <dc:creator>mgcunado</dc:creator>
      <pubDate>Fri, 25 Mar 2022 10:22:47 +0000</pubDate>
      <link>https://forem.com/mgcunado/raw-query-in-sequilize-model-1n4</link>
      <guid>https://forem.com/mgcunado/raw-query-in-sequilize-model-1n4</guid>
      <description>&lt;p&gt;Good Morning,&lt;/p&gt;

&lt;p&gt;I have this in my sportcenter's model using sequelize:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Sequelize from 'sequelize';

export default (sequelize, DataTypes) =&amp;gt; {
    const Sportcenter = sequelize.define('Sportcenter', {
        id: {
            autoIncrement: true,
            type: DataTypes.INTEGER.UNSIGNED,
            allowNull: false,
            primaryKey: true,
        },
        name: {
            type: DataTypes.STRING(500),
            allowNull: true,
        },
        counter: {
            type: DataTypes.VIRTUAL,
        },
      ...
    });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The fields id and name are in database table, but counter is not. I want to relate "counter" with the raw query (e.a. "select count(id) from sportcenter") and then see it in the json output in the api:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "id": 1,
    "name": "Gorka",
    "counter": 26,
},
{
    "id": 2,
    "name": "Pedro",
    "counter": 26,
},
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;how can i get that?&lt;/p&gt;

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