Skip to content

[RFC] Transactions: provide a consistent interface for passing and sharing pipelines and multis #31

@tylr

Description

@tylr

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...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions