cozy / cozy-client

Document store and React components for the Cozy platform
MIT License
13 stars 12 forks source link

[VO-874] feat: Improve index naming #1495

Closed cballevre closed 2 months ago

cballevre commented 2 months ago

Index naming has two weaknesses:

This can cause differences between the expected result and the result when modifying queries.

An example of the new index name:

Query definition :

Q('io.cozy.files')
  .where({
    type: 'file',
  })
  .partialIndex({
    class: {
      $or: ['image', 'pdf'] 
    }
    trashed: {
      $eq: false 
    }
  })
  .sortBy([
    { name: 'desc' }
  ])

Old index name : _design/by_type_and_name_filter_class_and_trashed New index name : _design/by_type_and_name_filter_(class_(image_$or_pdf))_and_(trashed_$eq_false)

paultranvan commented 2 months ago

Related to https://github.com/cozy/cozy-client/issues/1374

Crash-- commented 2 months ago

So much cleaner than what I did before 👏 👏

Since you have changed the index name, you're going to have a pretty heavy DB server load when you release an app with this (mainly app with services ;))

In fact you're just going to update the name of the index, it should be ok.

paultranvan commented 2 months ago

Since you have changed the index name, you're going to have a pretty heavy DB server load when you release an app with this (mainly app with services ;))

Since we migrate the existing index through a copy, we should avoid a too much consequent load (i.e. we don't recompute index)

Crash-- commented 2 months ago

Yep, I updated my comment just before yours ;).

Just a last thing: I know that we had conflicts between the sack and cozy-client about index name. A few users had blank page because of this. I think that stack use partialFilters on some place, I'll double check that ;).

paultranvan commented 2 months ago

A few users had blank page because of this. I think that stack use partialFilters on some place, I'll double check that ;).

If you find any info about this, that would be precious!