cozy / cozy-client

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

Share code logic between StackLink and PouchLink #786

Open Crash-- opened 4 years ago

Crash-- commented 4 years ago

ATM, we do not share code logic between those 2 links.

For instance we implement in both side the method to generate the name and the fields for an instance : https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L284-L285

https://github.com/cozy/cozy-client/blob/master/packages/cozy-stack-client/src/DocumentCollection.js#L337-L339

And if we look closer to https://github.com/cozy/cozy-client/blob/cdf570a6dad2ec484c5a0537510bd68559272f4b/packages/cozy-stack-client/src/DocumentCollection.js#L428 we see that we're not using indexedField at all and it's problematic. (PR coming to fix that specific issue).

I'm wondering if we have more logic than just "indexedField" we can share between Stack and PouchLink.

Crash-- commented 4 years ago

I like the idea submitted by @paultranvan (come on, you have read the PouchDB's logs too much) to create a cozy-query-plan module.

@ptbrowne Any objection? or ideas?

Let's see how & when we can do that :)