<?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: krishna404</title>
    <description>The latest articles on DEV Community by krishna404 (@krishna404).</description>
    <link>https://dev.to/krishna404</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%2F586650%2Fa3e03d32-5c75-49b8-9eeb-b39c09fd50f0.jpeg</url>
      <title>DEV Community: krishna404</title>
      <link>https://dev.to/krishna404</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/krishna404"/>
    <language>en</language>
    <item>
      <title>Challenges with Offline First Framework</title>
      <dc:creator>krishna404</dc:creator>
      <pubDate>Fri, 04 Jun 2021 03:46:20 +0000</pubDate>
      <link>https://dev.to/krishna404/challenges-with-offline-first-framework-2kkn</link>
      <guid>https://dev.to/krishna404/challenges-with-offline-first-framework-2kkn</guid>
      <description>&lt;h2&gt;
  
  
  Almost all the apps don't work without internet. What are the challenges of making a work with patchy &amp;amp; intermittent internet.
&lt;/h2&gt;

&lt;p&gt;Remember the song 'Cloud Number 9' by Bryan Adams? Well here's the video either ways... &lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/QhO-4cCQSUU"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;In today's world we practically live in the cloud. Always connected to internet, we are already cyborgs &amp;amp; our devices are our connection to the singularity. We will have to make do with this low bandwidth solution unless a Neuralink solution which directly wires the computers to our brains is developed. Well just think how frustrated we get when our apps don't work for lack of connection. Now I am making an app which would work even in lack of internet. Welcome to world of magic! 🪄&lt;/p&gt;

&lt;p&gt;So I am building a project using databases called &lt;a href="https://couchdb.apache.org"&gt;CouchDB&lt;/a&gt; &amp;amp; &lt;a href="https://pouchdb.com"&gt;PouchDB&lt;/a&gt;. I have &lt;a href="https://krishna404.com/pouchdb-find-is-not-a-function"&gt;talked them first here where PouchDB was giving me trouble&lt;/a&gt;, it turned out be me not knowing my javascript good enough. 🙈&lt;/p&gt;

&lt;p&gt;So as I keep going deeper into the project, I am coming up against other issues that wouldcome upp with a Offline-First Implementation. It's a revelation of sorts how it is so difficult to get to the root of the problems by just thinking about them. It's the building that takes you to the trenches &amp;amp; you get face-to-face with what has been hiding in plain sight.&lt;/p&gt;

&lt;p&gt;So here are the factors that you need to consider when going for a Offline First implementation.&lt;/p&gt;

&lt;p&gt;Now lets talk about the simple architecture when using PouchDB &amp;amp; CouchDB&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--t4Y3UmXJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rhtr70xenrfizux7agb4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--t4Y3UmXJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rhtr70xenrfizux7agb4.png" alt="image"&gt;&lt;/a&gt;   &lt;/p&gt;

&lt;h3&gt;
  
  
  Stale Data:
&lt;/h3&gt;

&lt;p&gt;In a Online First architecture, the app just shows internet not available &amp;amp; doesn't allow any functionality on the app. The App basically becomes useless. That is not the case in an offline-first app.&lt;/p&gt;

&lt;p&gt;In the absence of any internet connection, PouchDB would just return the latest data available with it from the last successful sync. Many times this could pose a significant issue. We often see this problem occuring during shopping online, when the old prices are shown again because of caching issues.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conflict of Data:
&lt;/h3&gt;

&lt;p&gt;Now taking the above idea further. Think if the data is shared among many users who work in the same company or team. Now if one of the users who has a bad internet connection works on the stale data &amp;amp; updates it. It leads to Conflict in data, which needs to be resolved seperately.&lt;/p&gt;

&lt;p&gt;See this image below where i have tried to visualise the concept.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--r48XFqoY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rkfbnpcabuntgkkmrmcc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--r48XFqoY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rkfbnpcabuntgkkmrmcc.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Updating the Users Auth data:
&lt;/h3&gt;

&lt;p&gt;Now this is a very developer specific problem. You always want to route the user-authentication only by the database on server. Now if the user wants to update their password or any of other user auth details, they have to disabled to when the user is offline.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data Loss when user goes offline:
&lt;/h3&gt;

&lt;p&gt;In an offline first, the user could still input data when offline. Now the above infrastructure allows us to do that. The App just Reads &amp;amp; Writes to the local PouchDB database instance which is always available to itself. It is responsibility of PouchDB to sync this data with the CouchDB database sitting in the server. In the absence of internet, PouchDB patiently keeps trying at intervals to establish connection &amp;amp; sync the data.&lt;/p&gt;

&lt;p&gt;Due to multiple reasons this data can get lost from the user side just because the data didn't have the opportunity to connect &amp;amp; sync with the server.&lt;/p&gt;

&lt;h3&gt;
  
  
  Handling Privacy:
&lt;/h3&gt;

&lt;p&gt;When ever the user Logins, the PouchDB instance pulls a copy of the database to the local machine. Now having this data always on the user machine could pose risks related to security. Other Apps may try to snoop &amp;amp; read into this data. This calls for encryption of data, the most safe is to do it right from the server side. Thankfully CouchDB allows for this.&lt;/p&gt;

&lt;h3&gt;
  
  
  Handling Logouts:
&lt;/h3&gt;

&lt;p&gt;Now the best practice is to delete all the resident data whenever the user logouts. But is that always a good choice? And what happens if the user has been able to logout for multiple reason &amp;amp; session-cookies have expired? Does the data stay persistently on the users system?&lt;/p&gt;

&lt;p&gt;This could lead to many instances of the database clogging up precious space on the users system. After all the space available to PWAs is rationed as per allotted quota.&lt;/p&gt;

&lt;h3&gt;
  
  
  Background Data Change:
&lt;/h3&gt;

&lt;p&gt;If 2 or more people are working on the same data how do we keep each up-to-date with other. Now just thinking about the way Google Docs &amp;amp; other such collaboration tools would do that kind makes me go dizzy but I can understand they do it in some kind of a shared-state framework.&lt;/p&gt;

&lt;p&gt;How does somebody like me who is working with forms implement this?&lt;/p&gt;

&lt;p&gt;Now I have figured a neat way this can be done even with forms but I want to talk about it once I have coded this after all there is a lot of minute details you figure only when you are building. I want that to be a complete guide for doing this.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion:
&lt;/h3&gt;

&lt;p&gt;Now the above is not the exhaustive list of challenges which need to addressed in a Offline-First framework but if you have covered for the above, I would say you have covered more than 90% of the issues.&lt;/p&gt;

&lt;p&gt;Now offline first apps are great when there isn't a lot of team collaboration. Or if the teams have siloed work structure. Now lets say a company wants an app for their sales people who are always travelling &amp;amp; often have patchy internet. This would be a great framework, as the chances that 2 sales-person would have different regions, customers, etc... assigned. So a chance of any conflict happening on this end is almost negligible.&lt;/p&gt;

&lt;p&gt;But Offline-First framework is not advisable for something like a Forex Trading Platform where the data can't be stale. In the absence of internet not allowing the user to use the App is a feature &amp;amp; not a bug in this case.&lt;/p&gt;

&lt;p&gt;So if you are choosing Offline First Framework for your app think about the why deeply as this increases the complexity of your app by a few degrees at least.&lt;/p&gt;

&lt;p&gt;Keep Smiling :)&lt;br&gt;
Krishna.&lt;/p&gt;

</description>
      <category>offline</category>
      <category>couchdb</category>
      <category>systems</category>
      <category>design</category>
    </item>
    <item>
      <title>What makes a Impressive Web Developer Portfolio</title>
      <dc:creator>krishna404</dc:creator>
      <pubDate>Mon, 31 May 2021 15:27:53 +0000</pubDate>
      <link>https://dev.to/krishna404/what-makes-a-impressive-web-developer-portfolio-bml</link>
      <guid>https://dev.to/krishna404/what-makes-a-impressive-web-developer-portfolio-bml</guid>
      <description>&lt;p&gt;Developers either freelancers or job seekers are hired based on their portfolio. But what makes for a good portfolio?&lt;/p&gt;

&lt;p&gt;So you are a developer &amp;amp; looking for a new gig or a job &amp;amp; everyone asks you for the portfolio? So what makes a good portfolio?&lt;/p&gt;

&lt;p&gt;First of all there is no one solution fits all scenario. The development field is vast &amp;amp; depending on your work area your portfolio needs will vary. This blog is directed towards web-developers but I am sure you can use the concepts discussed here for your own purpose.&lt;/p&gt;

&lt;p&gt;The first question that comes on the topic is "What kind of projects are valid?". &lt;/p&gt;

&lt;p&gt;The objective of creating these projects is to showcase the diversity of our talents. So our projects need to be from different domains. If we talk about basic CRUD apps, the app should allow all the 4 basic operations - Create, Read, Update &amp;amp; Delete. Throwing in a bit of data visualisation would really make it standout.&lt;/p&gt;

&lt;h2&gt;
  
  
  Kind of projects:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Social Media - like Facebook, Twitter&lt;/li&gt;
&lt;li&gt;e-Commerce - like Amazon, DTC brands&lt;/li&gt;
&lt;li&gt;Media Player - Netflix, Youtube&lt;/li&gt;
&lt;li&gt;Messaging, Group &amp;amp; Individual Chats - like WhatsApp, Telegram&lt;/li&gt;
&lt;li&gt;Productivity - like Asana, Trello&lt;/li&gt;
&lt;li&gt;Game, Extra points for Multiplayer games - anything simple like a Maze, Snake&lt;/li&gt;
&lt;li&gt;You can get more project ideas from  &lt;a href="https://www.producthunt.com/"&gt; Product Hunt&lt;/a&gt; ,  &lt;a href="https://www.reddit.com/r/AppIdeas/"&gt;r/appideas&lt;/a&gt; ,  &lt;a href="https://dribbble.com/"&gt;Dribble&lt;/a&gt; ,  &lt;a href="https://www.behance.net/"&gt;Behance&lt;/a&gt; , etc...
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQs
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How many projects?
&lt;/h3&gt;

&lt;p&gt;Ideally it should be 5 projects but the bare minimum is having 3 projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  Are clones ok?
&lt;/h3&gt;

&lt;p&gt;Yes making clones is ok but try to add / remove a feature, brand name. You can add a disclaimer in the footer that this is just for educational purposes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is it necessary to deploy &amp;amp; have a live version?
&lt;/h3&gt;

&lt;p&gt;Yes! It is mandatory to have a live version deployed. You can use anything basic like &lt;a href="https://www.heroku.com/about"&gt;heroku&lt;/a&gt; &amp;amp; &lt;a href="https://www.netlify.com/"&gt;netlify&lt;/a&gt; to deploy your apps. Extra points for using real world options like &lt;a href="https://aws.amazon.com/"&gt;AWS&lt;/a&gt;, &lt;a href="https://azure.microsoft.com/en-in/"&gt;Azure&lt;/a&gt;, etc...&lt;/p&gt;

&lt;h3&gt;
  
  
  Is basic websites ok?
&lt;/h3&gt;

&lt;p&gt;No! Basic websites are not ok as a project. Most companies are not looking for website builders.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is Backend heavy projects ok?
&lt;/h3&gt;

&lt;p&gt;There are more openings in Front-End rather than Backend today but if you are targeting more for a Full-Stack or Backend heavy role, go for it. Just use the best practices for API &amp;amp; also document your API. The bar for Backend is higher.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mandatory features:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;At least 2 apps should have a Backend &amp;amp; should be connected to it.&lt;/li&gt;
&lt;li&gt;At least 2 apps should have a Database &amp;amp; some kind of Database storage.&lt;/li&gt;
&lt;li&gt;At least 2 apps should have a Login Auth functionality with user specific features, for eg. Bookmark.&lt;/li&gt;
&lt;li&gt;Atleast 2 apps should have some kind of Routing feature used.&lt;/li&gt;
&lt;li&gt;All four operations of CRUD.&lt;/li&gt;
&lt;li&gt;You may use API mocking providers like  &lt;a href="https://miragejs.com/"&gt;miragejs&lt;/a&gt;  for other projects without back-end.&lt;/li&gt;
&lt;li&gt;It should be mobile friendly &amp;amp; preferrably responsive. If you cant make it responsive, limit the view-port to mobile width, so that it looks good even on desktop.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Good to have
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Have a few contributions to some Open Source projects &amp;amp; have them merged.&lt;/li&gt;
&lt;li&gt;Some Data Analysis &amp;amp; Visualisation.&lt;/li&gt;
&lt;li&gt;Contribution in &lt;a href="https://summerofcode.withgoogle.com/"&gt;GSoC&lt;/a&gt;, &lt;a href="https://developers.google.com/season-of-docs"&gt;GSoD&lt;/a&gt;&amp;amp; Hackathons.&lt;/li&gt;
&lt;li&gt;A fast-paced video walkthrough of the App with your commentary, highlighting any unique / challenging features. The reviewer doesn't have the time to go through your app in detail, make it  easy for him &amp;amp; bonus is you get to highlight unique features of the app.&lt;/li&gt;
&lt;li&gt;A Google Document talking about the system architecture of the app. If possible add reasons for choosing the said architecture.&lt;/li&gt;
&lt;li&gt;Tests incorporated in the project. The most basic of them are also OK. The idea is to let the reviewer know that you understand how it works.&lt;/li&gt;
&lt;li&gt;Optimised performance &amp;amp; lighthouse report.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Good Practices
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Add link for the deployed App, Repo, Video &amp;amp; Google Doc in your Resume.&lt;/li&gt;
&lt;li&gt;The github code should incorporate the Psuedocode. It makes the job of reviewer really easy.&lt;/li&gt;
&lt;li&gt;Your commits in github should have meaningful comments. Avoid comments like "A minor update" rather say "Added the close button".&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Good Examples
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Check out this &lt;a href="https://rahuldkjain.github.io/"&gt;portfolio of Rahul Jain&lt;/a&gt;. What a pleasure. Though this level is not needed. Something basic is also more than good enough.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I will add more as I come across them&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;This post is mostly inspired from the topics discussed &lt;a href="https://www.youtube.com/watch?v=Vrwltd0y7p0"&gt;here&lt;/a&gt;. Do watch!&lt;/li&gt;
&lt;li&gt;Here is another &lt;a href="https://beyond-average.hashnode.dev/how-to-build-a-great-developer-portfolio-examples-and-tools"&gt;post&lt;/a&gt; which goes into really a lot of detail on the topic.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hit me up with any questions you would have!&lt;/p&gt;

&lt;p&gt;Keep Smiling :)&lt;br&gt;
Krishna.&lt;/p&gt;

</description>
      <category>portfolio</category>
      <category>projects</category>
      <category>jobs</category>
      <category>webdev</category>
    </item>
    <item>
      <title>PouchDB.find is not a function</title>
      <dc:creator>krishna404</dc:creator>
      <pubDate>Sun, 30 May 2021 10:21:00 +0000</pubDate>
      <link>https://dev.to/krishna404/pouchdb-find-is-not-a-function-593h</link>
      <guid>https://dev.to/krishna404/pouchdb-find-is-not-a-function-593h</guid>
      <description>&lt;h2&gt;
  
  
  Debugging the Mango query Find for PouchDB Database for finding new documents.
&lt;/h2&gt;

&lt;p&gt;I am using  &lt;a href="https://couchdb.apache.org/"&gt;CouchDB&lt;/a&gt;  &amp;amp;  &lt;a href="https://pouchdb.com/"&gt;PouchDB&lt;/a&gt;  for one of my projects. &lt;/p&gt;

&lt;p&gt;Now CouchDB is an amazing database which is &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; - specifically designed for offline first applications.
 - Has great replication support. So is insanely scalable.
 - Gives user management out of the box.
 - Individual database for each user.
 - Manage roles &amp;amp; give access based to databases based on roles.
 - Allow custom query-design documents, which pre-indexes the database &amp;amp; which leads to fast read/write times.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Due to above reasons for basic CRUD type apps, you don't even need a backend(with insane security), that is great for both development time &amp;amp; cost optimisation.&lt;/p&gt;

&lt;p&gt;There are many more benefits to CouchDB, these are just at top of my mind. There are a few trade-offs too, so be mindful of those &amp;amp; see if this suites your needs. One of the major drawbacks is the community support lacking. Most of the articles are out-of-date &amp;amp;  most of the links are stale, this is often frustrating when you need an answer. It took me about 4 months to find the slack channel where the community lives. I believe it will be smooth sail from here. 🤞&lt;/p&gt;

&lt;p&gt;While CouchDB sits on the server, PouchDB is the database that sits on the client side. The app is supposed to talk to PouchDB &amp;amp; PouchDB then syncs with CouchDB behind the covers, so the app is not dependent on the server to be available. This neat structure is what allows CouchDB to be an awesome Offline First database. Do note, using PouchDB is not mandatory though.&lt;/p&gt;

&lt;h4&gt;
  
  
  Note: If you plan to use this or any other similar offline first mechanisms for your app understand about the trade-offs of offline first structure (whether, couchDB or not). Some risks that you will have to plan for
&lt;/h4&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  - Possibility of data loss when offline.
  - Data conflicts between the offline &amp;amp; online version.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;There are more, do your research before so that you are not surprised later &amp;amp; see if you can incorporate a contingency plans for any issues. CouchDB has a really good conflict management structure though.&lt;/p&gt;

&lt;p&gt;Now one of the most basics of using any database is querying. Other than the get method, CouchDB &amp;amp; PouchDB use  &lt;a href="https://pouchdb.com/guides/mango-queries.html"&gt;Mango queries&lt;/a&gt;. Which is very similar to MongoDB queries(the wordplay!!!).&lt;/p&gt;

&lt;p&gt;The most common query is &lt;code&gt;PouchDB.find&lt;/code&gt; which is actually written like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var res = await this.pouchDB.find(
                              {selector: 
                                    selector
                               }
                 )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now when I incorporated this in my solution, it kept throwing the error &lt;code&gt;PouchDB.find&lt;/code&gt; is not a function. Here is more detail on this...&lt;/p&gt;

&lt;h3&gt;
  
  
  Issue
&lt;/h3&gt;

&lt;p&gt;Cant using the mango query find. Getting error&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;PouchDB.find is not a function&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Info
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Environment: Browser - Reactjs&lt;/li&gt;
&lt;li&gt;Platform: Chrome&lt;/li&gt;
&lt;li&gt;Adapter: IndexedDB&lt;/li&gt;
&lt;li&gt;Server: CouchDB&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Reproduce
&lt;/h3&gt;

&lt;p&gt;Now as per the &lt;a href="https://pouchdb.com/guides/mango-queries.html"&gt;docs here&lt;/a&gt; we need to use plugin &lt;code&gt;pouchdb-find&lt;/code&gt; to be able to use Mango queries.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--j11S7lzc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jgbcbxa50rgrdi951y54.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j11S7lzc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jgbcbxa50rgrdi951y54.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But as mentioned &lt;a href="https://github.com/nolanlawson/pouchdb-find"&gt;here&lt;/a&gt; that pouchdb-find is now merged with pouchdb, so should not be needed at all.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F-oMnN9U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o8ijcdfq0l58dnzz03f0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F-oMnN9U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o8ijcdfq0l58dnzz03f0.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So I tried using pouchdb-find plugin with both pouchdb &amp;amp; pouchdb-browser. It just didnt work.&lt;/p&gt;

&lt;h4&gt;
  
  
  Options tried:
&lt;/h4&gt;

&lt;p&gt;Option1&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import PouchDB from 'pouchdb';
import pouchAuth from 'pouchdb-authentication';
PouchDB.plugin(pouchAuth);
PouchDB.plugin(require('pouchdb-find').default);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Option2&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import PouchDB from 'pouchdb';
import pouchAuth from 'pouchdb-authentication';
import pouchFind from 'pouchdb-find';
PouchDB.plugin(pouchAuth);
PouchDB.plugin(pouchFind);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Option3&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import PouchDB from 'pouchdb-browser';
import pouchAuth from 'pouchdb-authentication';
import pouchFind from 'pouchdb-find';
PouchDB.plugin(pouchAuth);
PouchDB.plugin(pouchFind);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Option4&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import PouchDB from 'pouchdb';
import pouchAuth from 'pouchdb-authentication';
PouchDB.plugin(pouchAuth);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Notes:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;pouchdb-authentication&lt;/code&gt; is need to provide authentication if you are using CouchDBs inbuilt user managment. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Well the glitch wasn't in the plugin at all. It was about how the database was being called. So here is what I was doing&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import PouchDB from 'pouchdb-browser';
import pouchAuth from 'pouchdb-authentication';
import pouchFind from 'pouchdb-find';
PouchDB.plugin(pouchAuth);
PouchDB.plugin(pouchFind);

...

const getDB = (dbName) =&amp;gt; {

        const localDB = new PouchDB(dbName, {auto_compaction: true});

        return localDB;
}

const findDoc = async (input)=&amp;gt; {

         let db = await getDB(dbName).find({
                         selector: {
                            type: { $eq: props[2]}
                        },
                        limit: 1
                      })
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What worked for me was&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;... same as above
const findDoc = async (input)=&amp;gt; {

         let db = await getDB(dbName)
              db = await db.find({
                         selector: {
                            type: { $eq: props[2]}
                         },
                         limit: 1
                      })
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thankfully the community helped me figure this out. You can read about detail on the issue  &lt;a href="https://github.com/pouchdb/pouchdb/issues/8303"&gt;here at github&lt;/a&gt; .&lt;/p&gt;

&lt;p&gt;I don't know what is wrong in the first option. If you know, please do let me know.&lt;/p&gt;

&lt;p&gt;Caio till the next time.&lt;br&gt;
Krishna.&lt;br&gt;
Follow me at &lt;a href="https://krishna404.com"&gt;https://krishna404.com&lt;/a&gt; for Tech Blogs &amp;amp; More.&lt;/p&gt;

</description>
      <category>devjournal</category>
      <category>react</category>
      <category>database</category>
    </item>
  </channel>
</rss>
