Skip to content

Index all fields or a key/value entry #2128

Answered by dfahlander
tobiasBora asked this question in Q&A

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: "foo@bar.com",
  phone: "xxxxxxx".
  indexedValues: [
    ["email", "foo@bar.com"],
    ["phone", "xxxxxxx"],
    ...
  ]
}

Using this approach you would serach like this:

db.table
  .where('indexedValues')
  .equals(["email", "foo@bar.com"])
  .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: "foo@bar.com",
  phone: "xxxxxxx".

Replies: 1 comment 5 replies

You must be logged in to vote
5 replies
@tobiasBora

@dfahlander

Answer selected by tobiasBora
@tobiasBora

@tobiasBora

@dfahlander

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