Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Do not hydrate document with empty relationship data #1470

Closed
wants to merge 1 commit into from

Conversation

Merkur39
Copy link
Member

Cette PR propose un changement important dans le comportement de l'hydratation des documents! (voir le message de commit)

This commit changes the behavior of document hydration,
from now on the document will no longer be hydrated
with relationships that have no data.

Example:
```
const schema = {
     ...
     relationships: {
         books: {
             type: 'has-many',
             doctype: "io.cozy.books"
         },
         authors: {
             type: 'has-many',
             doctype: "io.cozy.authors"
         }
     }
}

{
     _id: "my_doc",
     relationships: {
         books: {
             data: [{ _id: "01", _type: "io.cozy.books" }]
         }
     }
}

```
will be hydrated as follows:
```
{
     _id: "my_doc",
     books: <HasMany object>,
     relationships: {
         books: {
             data: [{ _id: "01", _type: "io.cozy.books" }]
         }
     }
}
```
instead of :
```
{
     _id: "my_doc",
     books: <HasMany object>,
     authors: <HasMany object>,
     relationships: {
         books: {
             data: [{ _id: "01", _type: "io.cozy.books" }]
         }
     }
}
```
@Merkur39
Copy link
Member Author

I'm closing this, the approach isn't good. It's probably better to act on the "dehydrate" methods instead.

@Merkur39 Merkur39 closed this May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant