JackAdams / meteor-transactions

App level transactions for Meteor + Mongo
http://transactions.taonova.com/
MIT License
113 stars 16 forks source link

Transaction data set correctly, but action is not done #58

Open jetlej opened 8 years ago

jetlej commented 8 years ago

I'm getting what looks to be correct messages in console, but the action itself is not being done in the first place.

VM1659 babrahams_transactions.js?hash=8ed90df…:110 Started "update article" with transaction_id: 3zwh9dmfJyfhZ8XWB (auto started)
2VM1659 babrahams_transactions.js?hash=8ed90df…:110 Pushed update command to stack: 3zwh9dmfJyfhZ8XWB
VM1659 babrahams_transactions.js?hash=8ed90df…:110 Auto committed: 3zwh9dmfJyfhZ8XWB
VM1659 babrahams_transactions.js?hash=8ed90df…:110 Beginning commit with transaction_id: 3zwh9dmfJyfhZ8XWB

Relevant line of code: return Articles.update(query, { $set: data }, {tx: true});

JackAdams commented 8 years ago

Just check that the query object has an _id value set (the transactions package ignores everything else in the object). That query isn't treated like a true mongo selector (at all). See 1. here.

jetlej commented 8 years ago

The query object definitely has an _id value set, and it's the only value set in that object.

Here's some more sample code (defined as Meteor methods):

approveArticle: function(id, owner) {
    Meteor.call('updateArticle', id, {
        status: STATUS_APPROVED,
        owner: null,
        lastChanged: new Date()
    });
},

updateArticle: function(id, data) {
    return Articles.update({_id: id}, { $set: data }, {tx: true});
}

Any other suggestions?

jetlej commented 8 years ago

Bump

JackAdams commented 8 years ago

Hmmm... not sure what to suggest here. That code looks fine to me. Note: the return value from the method shown above will not be the return value from the mongo update command, it will just be true if the transaction has been completed as expected.

If there's a minimal repro I could look at I could figure out what's going on.