lightblue-platform / lightblue-core

Document based data access layer framework
GNU General Public License v3.0
32 stars 23 forks source link

Associations should support self-reference #639

Open bserdar opened 8 years ago

bserdar commented 8 years ago

We need a way to refer to the same document within associations, to do something like this { array: [ {uid:1,... } {uid:2, parent:1,... } ] }

array elements refer to each other via uid. Second element refers to its parent. But the second element also wants to project some fields of the parent within itself. Currently, this can be done by looking up the same document again. Instead, the metadata should refer to $self in query, and use only projection to inject the current document.

jewzaam commented 7 years ago

This is similar to https://github.com/lightblue-platform/lightblue-core/issues/425 and would allow us to break away from the 1:1 mapping from metadata to mongo documents we currently have, but be usable by any backend if implemented in core.

bserdar commented 7 years ago

How is this similar to #425?

jewzaam commented 7 years ago

Similar in that they're both having a field that has no actual data behind it that's being populated by some other field in that document. In this case it's based on data that's exposed in metadata. In #425 it's data in the backend only, not necessarily exposed via metadata.