<?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: Sami Salih İbrahimbaş</title>
    <description>The latest articles on DEV Community by Sami Salih İbrahimbaş (@ssibrahimbas).</description>
    <link>https://dev.to/ssibrahimbas</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%2F870067%2Fb7d1427b-6a9c-4bea-8cd6-1a59bc950311.jpeg</url>
      <title>DEV Community: Sami Salih İbrahimbaş</title>
      <link>https://dev.to/ssibrahimbas</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ssibrahimbas"/>
    <language>en</language>
    <item>
      <title>ORM vs Core Database Driver</title>
      <dc:creator>Sami Salih İbrahimbaş</dc:creator>
      <pubDate>Mon, 25 Jul 2022 19:57:00 +0000</pubDate>
      <link>https://dev.to/ssibrahimbas/orm-vs-core-database-driver-2nn5</link>
      <guid>https://dev.to/ssibrahimbas/orm-vs-core-database-driver-2nn5</guid>
      <description>&lt;p&gt;Greetings, in this article we will briefly talk about the comparison of ORM and database drivers and which one you should perfer in which situation.&lt;/p&gt;

&lt;h2&gt;
  
  
  ORM Pros and Cons
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Pros
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Schemas/Entites are clearly defined.&lt;/li&gt;
&lt;li&gt;Relatively easy to understand and develop&lt;/li&gt;
&lt;li&gt;You can write basic Queries with built-in query-builders&lt;/li&gt;
&lt;li&gt;You don't bother too much with database operations&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cons
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Low performance&lt;/li&gt;
&lt;li&gt;As it is a pattern applied on top of the engine, it may restrict some advanced operations&lt;/li&gt;
&lt;li&gt;Extra dependencies and possible size growth for the project (the item may sound trivial but will be important when using docker and etc.)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Database Driver Pros and Cons
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Pros
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;High performance&lt;/li&gt;
&lt;li&gt;Takes up minimal space&lt;/li&gt;
&lt;li&gt;Trouble-free guarantee and full documentation as it was developed by the database company&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cons
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;May require expertiese with queries and databases&lt;/li&gt;
&lt;li&gt;Schemas are not clearly defined or have no effect on the database&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When, Which?&lt;/p&gt;

&lt;p&gt;If you are developing a simple demo, developing a blog, or if time and performance (included build time and performance) is not important to you; your choice should be ORM.&lt;/p&gt;

&lt;p&gt;If time and performance (included build time and performance) is your thing, if you're a database expert; your choice should be Core Database Driver.&lt;/p&gt;

&lt;p&gt;Here is &lt;a href="https://blog.jscrambler.com/mongodb-native-driver-vs-mongoose-performance-benchmarks"&gt;an article&lt;/a&gt; measuring the differences between mongodb and mongoose, there is a really big performance difference.&lt;/p&gt;

&lt;p&gt;If you're lazy, there's a table like this at the end of the article.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;READS&lt;/th&gt;
&lt;th&gt;Native&lt;/th&gt;
&lt;th&gt;Mongoose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Throughput&lt;/td&gt;
&lt;td&gt;1200 #/sec&lt;/td&gt;
&lt;td&gt;583 #/sec&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Avg Request&lt;/td&gt;
&lt;td&gt;0.83 ms&lt;/td&gt;
&lt;td&gt;1.71 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;WRITES&lt;/th&gt;
&lt;th&gt;Native&lt;/th&gt;
&lt;th&gt;Mongoose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Throughput&lt;/td&gt;
&lt;td&gt;1128 #/sec&lt;/td&gt;
&lt;td&gt;384 #/sec&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Avg Request&lt;/td&gt;
&lt;td&gt;0.89 ms&lt;/td&gt;
&lt;td&gt;2.60 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Whay do you think about this subject?&lt;/p&gt;

</description>
      <category>database</category>
      <category>orm</category>
      <category>mongodb</category>
      <category>discuss</category>
    </item>
    <item>
      <title>With Dynamic SQL Queries on TypeScript &amp; NodeJS</title>
      <dc:creator>Sami Salih İbrahimbaş</dc:creator>
      <pubDate>Fri, 10 Jun 2022 19:01:17 +0000</pubDate>
      <link>https://dev.to/ssibrahimbas/with-dynamic-sql-queries-on-typescript-nodejs-3o2o</link>
      <guid>https://dev.to/ssibrahimbas/with-dynamic-sql-queries-on-typescript-nodejs-3o2o</guid>
      <description>&lt;p&gt;Hello,&lt;br&gt;
In this article, I will show you how to write a more dynamic, fast and sustainable SQL queries with &lt;code&gt;@ssibrahimbas/query&lt;/code&gt; package, which is the npm package I wrote with my own keyboard.&lt;/p&gt;

&lt;p&gt;This package creates you SQL queries. But it doesn't run them. We usually use ready-made SQL clients (like sequelize, pg) to run SQL queries in NodeJS. I developed this package only as a query-builder by making use of the Single Responsibility pattern. It's the job of sequelize or pg to execute the query. Whichever you want!&lt;/p&gt;

&lt;p&gt;Let's install the npm package&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install @ssibrahimbas/query&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;for yarn &lt;code&gt;yarn add @ssibrahimbas/query&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Okey, now let's create an index.js file and code it&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="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Query&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@ssibrahimbas/query&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;Query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;table&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;users&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;getAll&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;The process here is to create the query that returns the id and name field if id 1 from the users table.&lt;/p&gt;

&lt;p&gt;When we run the code we will get the following result:&lt;br&gt;
&lt;code&gt;SELECT id FROM users WHERE id = '1'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Better install a driver and give it a try on the real database! It was developed entirely with TypeScript, full support for TypeScript &amp;amp; JavaScript and has +50 unit tests. And the documentation is pretty good too!&lt;/p&gt;

&lt;p&gt;I would be grateful if you share your experiences as comments.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.npmjs.com/package/@ssibrahimbas/query"&gt;Npm Package&lt;/a&gt;&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>sql</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
