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

multiple SubCollections with same Entity #250

Open
danieleisenhardt opened this issue Apr 26, 2021 · 2 comments
Open

multiple SubCollections with same Entity #250

danieleisenhardt opened this issue Apr 26, 2021 · 2 comments

Comments

@danieleisenhardt
Copy link
Contributor

This will cause an error to be thrown:

class Album {
  id: string;
  name: string;
}

@Collection()
class Band {
  id: string;
  name: string;
  @SubCollection(Album, 'albums')
  albums: ISubCollection<Album>;
  @SubCollection(Album, 'singles')
  singles: ISubCollection<Album>;
}

There are obvious workarounds, but I believe this should not cause an error.

I tried to fix it on my fork, however MetadataStorage.setCollection() seems to evaluate children before parents and updating the segments afterwards using a getWhereImParent() function. It becomes more of a design choice than a simple bug fix at this point, please advise.

@darmie
Copy link

darmie commented Apr 6, 2022

We need a solution for this, I am having the same problem

@danieleisenhardt
Copy link
Contributor Author

I have not had the time to make a solution myself. (since last year, I know)

A workaround is to extend the class i.e.
class Single extends Album

If you really need a solution you can always make a pull request yourself.

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

No branches or pull requests

2 participants