brianloveswords / streamsql

A streaming, backend agnostic SQL ORM heavily inspired by levelup
MIT License
67 stars 7 forks source link

Extended linked data #13

Closed andrewhayward closed 10 years ago

andrewhayward commented 10 years ago

Should {relationships: true} queries also include the relationships of related entities?

For example, an application has a related badge. A badge has a related system (and potentially issuer and program). Querying applications retrieves the associated badge, but the associated badge doesn't have a reference to its system, issuer or program.

brianloveswords commented 10 years ago

I don't think {relationships: true} should do that, but I think there should be a way to specify the depth of relationship fulfillment.

I briefly looked into this while I had an hour or two free, but it was more than an hour or two of work so I shelved it for now. The code for relationship fulfillment is kind of hairy – it uses joins, not multiple queries – and trying to untangle the output from a deep relationship fulfillment was proving difficult to me. For deep relationships, I might have to resort to multiple queries, unless you can think of an elegant way to do it with joins and detangle the output!

andrewhayward commented 10 years ago

I've opened a pull request (#14) that theoretically resolves this. Fortunately, I think I managed to untangle the output from the joins, so it's still using them for hasOne relationships.