cozy / cozy-browser-sdk

Cozy Data System client for the browser
http://dev.cozy.io
MIT License
7 stars 12 forks source link

[Doc] Multiple defineView? #33

Open Phyks opened 7 years ago

Phyks commented 7 years ago

Hi,

I am quite new to CouchDB, so I might miss something, but how are multiple defineView handled? I have two main concerns:

  1. First one is that if I defineView a previously defined view, it will overwrite it. Is there any plans (maybe in the long term) to ensure a Cozy app cannot override pre-existing views and potentially break other installed apps?
  2. When multiple apps get installed, all of them will populate the views by defining their own. But nothing seems to clean the defined views, for example when apps are uninstalled. Then, the number of views in the CouchDB can only keep increasing. Is there any mechanism to clean the useless views or is it of no importance?

Thanks!

clochix commented 7 years ago

Ping @aenario

aenario commented 7 years ago

defineView does not override pre-existing view (in production), if you attempt to create a view which would conflict with an existing one, your view is created with a prefix from your application (see https://github.com/cozy/cozy-data-system/blob/master/server/lib/request.coffee).

Because the data-system does not keep track of which view is created by what application, we cannot perform clean up of views. It is an issue and do make old cozy slower, but because the number of applications for cozy is not that big, it was manageable on stack v1. One of the design goals of cozy-stack v2 is to avoid this issue by keeping track of what views are defined / used by each application.

Phyks commented 7 years ago

Ok! Thanks