How to use the pouchdb-selector-core.matchesSelector function in pouchdb-selector-core

To help you get started, we’ve selected a few pouchdb-selector-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ArnoSaine / react-pouchdb / src / api / useFind.js View on Github external
async ({ deleted, doc }) => {
          const index = docs?.findIndex(({ _id }) => doc._id === _id);
          const found = index !== -1;
          // Document was deleted or it does not match the selector?
          if (deleted || (selector && !matchesSelector(doc, selector))) {
            if (found) {
              // Remove.
              docs.splice(index, 1);
              const { length } = docs;
              // At the limit?
              if (length + 1 === limit) {
                const {
                  docs: [replacementDoc]
                } = await db.find({
                  ...options,
                  limit: 1,
                  skip: (options.skip || 0) + length
                });
                if (replacementDoc) {
                  docs.push(replacementDoc);
                }