Skip to content

Commit

Permalink
feat: Add a warning when an indexedField is missing in query selector
Browse files Browse the repository at this point in the history
This replies to #1506 (comment)
  • Loading branch information
Ldoppea committed Sep 24, 2024
1 parent 66e8275 commit 3133d09
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/cozy-pouch-link/src/helpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import startsWith from 'lodash/startsWith'

import logger from './logger'

const helpers = {}

// https://github.com/pouchdb/pouchdb/issues/7011
Expand Down Expand Up @@ -66,6 +68,10 @@ helpers.normalizeFindSelector = (selector, indexedFields) => {
if (indexedFields) {
for (const indexedField of indexedFields) {
if (!Object.keys(findSelector).includes(indexedField)) {
const selectorJson = JSON.stringify(selector)
logger.warn(
`${indexedField} was missing in selector, it has been automatically added from indexed fields. Please consider adding this field to your query's selector as required by PouchDB. The query's selector is: ${selectorJson}`
)
findSelector[indexedField] = {
$gt: null
}
Expand Down

0 comments on commit 3133d09

Please sign in to comment.