In order to solve the O(n) problem when fetching nested objects we should consider an interface / API for shared pipelines when fetching data.
There are a few known patterns for solving this problem, I think the best will be found through practical implementations. One approach would be providing a Promise like interface for queueing up fetches. Perhaps something that works similarly to Promise.spread() that provides a single multi or pipeline to an array of radredis calls...
Through es6 we could have an easy to use and understand interface that used object destructuring to implement transaction wide pipelines.
Radredis.tx(Person.all, [Post.find, [1,2,3]])
// Internally
function find(ids, { pipeline }) {
// use the pipeline...
}
It also seems sensical to provide the pipeline to certain callbacks / transforms.
const transforms = { onFind: (person, { pipeline }) => ({
person.findFriends({ pipeline })
}) }
More to come...