<?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: Andreas Brain</title>
    <description>The latest articles on DEV Community by Andreas Brain (@abrain).</description>
    <link>https://dev.to/abrain</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%2F88103%2Fbbe139ab-a268-40cc-8ce9-027f73357746.jpeg</url>
      <title>DEV Community: Andreas Brain</title>
      <link>https://dev.to/abrain</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abrain"/>
    <language>en</language>
    <item>
      <title>Should I call Mongoose from the Express middleware?</title>
      <dc:creator>Andreas Brain</dc:creator>
      <pubDate>Tue, 24 Mar 2020 19:50:02 +0000</pubDate>
      <link>https://dev.to/abrain/should-i-call-mongoose-from-the-express-middleware-kel</link>
      <guid>https://dev.to/abrain/should-i-call-mongoose-from-the-express-middleware-kel</guid>
      <description>&lt;p&gt;When you look for tutorials about building a REST API with Express and Mongoose, the vast majority includes snippets like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/users&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;find&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;Is it a good practice to directly access Mongoose Models from the Express middleware without any abstraction?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>node</category>
    </item>
  </channel>
</rss>
