psr7-demo icon indicating copy to clipboard operation
psr7-demo copied to clipboard

Transactions support

Open billdami opened this issue 10 years ago • 2 comments

Do you plan on adding transaction support at any point in the future? Or do you recommend just using firebase references directly for this?

billdami avatar Oct 21 '14 15:10 billdami

At the moment I'd recommend dropping down to raw firebase references, but would certainly be open to suggestions on how this would look if it was built in.

rlivsey avatar Oct 22 '14 12:10 rlivsey

This is just off the top of my head, and I'm not sure if this would cover every use case, but what about something like this:

record.transaction('attrName', function(currentValue) {
    return (currentValue || 0) + 1;
});

Where the first parameter attrName is the name of the property that you want to atomically update on the given record, and the second parameter is the update function. Just like save() and delete(), transaction() would also return a promise.

billdami avatar Oct 22 '14 13:10 billdami