<?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: leran500</title>
    <description>The latest articles on DEV Community by leran500 (@leran500).</description>
    <link>https://dev.to/leran500</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%2F1093029%2F9d9d5daf-e792-4f12-bb0c-c9b5aaed159e.png</url>
      <title>DEV Community: leran500</title>
      <link>https://dev.to/leran500</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/leran500"/>
    <language>en</language>
    <item>
      <title>mongoose v7 pre hook error</title>
      <dc:creator>leran500</dc:creator>
      <pubDate>Wed, 31 May 2023 12:03:09 +0000</pubDate>
      <link>https://dev.to/leran500/d-1g5i</link>
      <guid>https://dev.to/leran500/d-1g5i</guid>
      <description>&lt;p&gt;i am using Mongoose v7.x in my nestJS projec, i want to use pre hook with where condition like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const schema = JsonSchemaSchema;
      //Pre middleware will apply on any Query middleware that start with find or update or delete)
      schema.pre(new RegExp('(find|update|delete)'), function () {
        this.where({
          ...buildNotDeletedCondition(),
          ...authorizationService.buildEntitiesAuthCondition(),
        });
      });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;but i am geeting the following error:&lt;br&gt;
` Property 'where' does not exist on type '(Document&amp;gt; &amp;amp; Omit &amp;amp; Required&amp;lt;{ _id: ObjectId; }&amp;gt;, never&amp;gt;) | Query&amp;lt;...&amp;gt;'. Did you mean '$where'?&lt;br&gt;
  Property 'where' does not exist on type 'Document&amp;gt; &amp;amp; Omit &amp;amp; Required&amp;lt;{ _id: ObjectId; }&amp;gt;, never&amp;gt;'.&lt;/p&gt;

&lt;p&gt;12         this.where({&lt;br&gt;
                ~~~~~&lt;/p&gt;

&lt;p&gt;`&lt;/p&gt;

&lt;p&gt;my code work fine in mongoose v6. anyone know how i could solve this?&lt;/p&gt;

</description>
      <category>mongoose</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
