Skip to content

Index all fields or a key/value entry #2128

Answered by dfahlander
tobiasBora asked this question in Q&A
Discussion options

You must be logged in to vote

You could take one of two approaches.

  1. Have the property name and its value in the multiEntry array:
{
  email: "[email protected]",
  phone: "xxxxxxx".
  indexedValues: [
    ["email", "[email protected]"],
    ["phone", "xxxxxxx"],
    ...
  ]
}

Using this approach you would serach like this:

db.table
  .where('indexedValues')
  .equals(["email", "[email protected]"])
  .toArray()
  1. Store only the values and let IndexedDB filter on the values. Then filter the rest manually. The upside with this is that you can do fuzzy searches on all fields in one query. The majority of filtering would happen in indexedDB still - and that's the key importance for optimization.
{
  email: "[email protected]",
  phone: "xxxxxxx".

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@tobiasBora
Comment options

@dfahlander
Comment options

Answer selected by tobiasBora
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants