Skip to content

Conversation

@ABWalters
Copy link

@ABWalters ABWalters commented Jul 24, 2018

Using the following search options:

const opts = {
    query: queryParam,
    fields: ['field1', 'field2'],
    include_docs: true,
    highlighting: true,
  };

If field1 matches the queryParam, but field2 does not exist in the document, then the following exception is thrown:

TypeError: Cannot read property 'replace' of undefined
    at \node_modules\pouchdb-quick-search\lib\index.js:421:23
    at Array.forEach (<anonymous>)
    at \node_modules\pouchdb-quick-search\lib\index.js:418:33
    at Array.forEach (<anonymous>)
    at \node_modules\pouchdb-quick-search\lib\index.js:411:42
    at process._tickCallback (internal/process/next_tick.js:68:7)

Some documents in the database do not have field2.

This small check will allow for search and highlighting with inconsistent DB schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant